FTJ
← Blog
Developer

HTML Entities: What They Are and How to Use Them

Struggling with < and > showing up as raw HTML? Here's how HTML entities work and a free tool to encode/decode them instantly.

HTML entities are special codes used to represent characters that have reserved meanings in HTML or characters that cannot be typed on a standard keyboard.

What Are HTML Entities?

HTML entities start with an ampersand (&) and end with a semicolon (;). They represent characters that would otherwise be interpreted as HTML markup:

CharacterEntityDescription
<&lt;Less than
>&gt;Greater than
&&amp;Ampersand
"&quot;Double quote
'&apos;Single quote
&nbsp;Non-breaking space
©&copy;Copyright
®&reg;Registered trademark
&euro;Euro sign
£&pound;Pound sign

When to Use HTML Entities

1. Reserved Characters

<!-- Wrong -->

<!-- Right --> <p>5 &lt; 10 and 10 &gt; 5</p> `

2. Special Symbols

<p>Price: &euro;50 or &pound;40</p>
<p>Copyright &copy; 2025</p>

3. Invisible Characters

<p>100&nbsp;km/h</p>

Numeric Entities

You can also use numeric codes:

CharacterDecimalHexadecimal
A&#65;&#x41;
©&#169;&#xA9;
&#8364;&#x20AC;

Common Mistakes

  1. Forgetting the semicolon&lt instead of &lt;
  2. Double encoding&amp;lt; instead of &lt;
  3. Encoding in attributestitle="5 &lt; 10" is correct
  4. Not encoding in code blocks — Inside <pre> and <code>, entities are still interpreted

Try It Online

## Common HTML Entities

  • &amp;& (ampersand — must be encoded in attributes and text)
  • &lt;< (less than — must be encoded to avoid being parsed as a tag)
  • &gt;> (greater than — technically optional but recommended)
  • &quot;" (double quote — must be encoded in attribute values delimited by double quotes)
  • &#39; or &apos;' (single quote — must be encoded in single-quoted attributes)
  • &nbsp; → non-breaking space (prevents line breaks at this point)
  • &copy;© (copyright symbol)
  • &reg;® (registered trademark)
  • &trade; (trademark)
  • &mdash; (em dash)
  • &ndash; (en dash)
  • &hellip; (ellipsis)

Numeric vs Named Entities

HTML entities come in two forms:

  • Named entities: &amp;, &copy;, &nbsp;. Easy to read and remember, but only a limited set is defined.
  • Numeric entities: &#38; (decimal) or &#x26; (hexadecimal) for &. Can represent any Unicode character.

For characters without named entities (like emojis or rare Unicode symbols), use numeric entities. For example, the copyright symbol can be written as &copy;, &#169;, or &#xA9; — all three are equivalent.

When to Use HTML Entities

  1. In HTML text content: Encode &, <, and > to avoid parsing issues.
  2. In attribute values: Encode &, <, >, and the matching quote character.
  3. In JavaScript strings: Use \u escapes or direct UTF-8 characters instead of HTML entities.
  4. In URLs: Use percent encoding (%20 for space), not HTML entities.
  5. In CSS: Use CSS escape sequences (\\ for backslash) or direct UTF-8 characters.

Modern HTML5 with UTF-8 encoding rarely needs entities for special characters — you can type © directly. But &, <, and > must always be encoded in HTML. Use our free HTML entities encoder/decoder to encode or decode HTML entities instantly — no installation needed.

Try These Tools

More Articles