What is HTML Entity?

An HTML entity is a coded representation of a character used to display reserved or special symbols in HTML without breaking the markup.

An HTML entity is a special sequence of characters used to represent a symbol in HTML that would otherwise be interpreted as markup or is difficult to type directly. Entities begin with an ampersand and end with a semicolon, with either a name or a numeric code in between — for example & for an ampersand, < for a less-than sign, and © for the copyright symbol.

Entities exist to solve two problems. First, certain characters are reserved by HTML itself: the less-than and greater-than signs delimit tags, and the ampersand starts an entity. To display these literally as text, you must escape them as <, >, and &, otherwise the browser tries to interpret them as structure and the page breaks or renders incorrectly.

Second, entities let you include characters that are hard to type or that might not survive certain encodings — accented letters, mathematical symbols, currency signs, arrows, and emoji. Named entities like € are readable, while numeric entities such as € (decimal) or € (hexadecimal) can represent any Unicode code point, making them a universal fallback.

Encoding and decoding entities is a routine task when handling user-generated content, preventing cross-site scripting by escaping untrusted input, or cleaning scraped HTML back into plain text. A frequent bug is double-encoding, where & appears because content was escaped twice. Understanding when text needs to be encoded for safe display versus decoded for readability avoids these mix-ups.

Examples

  • &lt; and &gt; display literal < and > without being treated as tags
  • &amp; displays a literal ampersand
  • &#8364; and &euro; both render the euro sign €

Frequently asked questions

Free tools for working with HTML Entity

Related terms