HTML Entity Reference: Named, Decimal, and Hex Formats

May 28, 20265 min read

What Are HTML Entity Formats?

HTML entities represent special characters using code sequences instead of the literal character. Three formats exist — named, decimal numeric, and hexadecimal numeric — and each serves a different purpose.

All three formats produce the same result. Choosing the right one depends on readability, compatibility, and the character you need.

Core Named Entities

These five named entities cover the characters that HTML itself reserves. You will use them constantly:

CharacterNamed EntityDecimalHexUse Case
&&&&Any time & appears as data
<&lt;&#60;&#x3C;Less-than sign in text
>&gt;&#62;&#x3E;Greater-than sign in text
"&quot;&#34;&#x22;Quotes inside attribute values
'&apos;&#39;&#x27;Apostrophes inside attribute values

Rule: Encode these five characters every time they appear as data inside HTML. Failing to do so can break your markup or open XSS vulnerabilities.

Common Symbols

CharacterNamed EntityDecimalHexDescription
©&copy;&#169;&#xA9;Copyright
®&reg;&#174;&#xAE;Registered trademark
&trade;&#8482;&#x2122;Trademark
&euro;&#8364;&#x20AC;Euro
£&pound;&#163;&#xA3;Pound sterling
¥&yen;&#165;&#xA5;Yen
°&deg;&#176;&#xB0;Degree
±&plusmn;&#177;&#xB1;Plus-minus
×&times;&#215;&#xD7;Multiplication
÷&divide;&#247;&#xF7;Division
&mdash;&#8212;&#x2014;Em dash
&ndash;&#8211;&#x2013;En dash
«&laquo;&#171;&#xAB;Left angle quote
»&raquo;&#187;&#xBB;Right angle quote
&nbsp;&#160;&#xA0;Non-breaking space

Numeric Entities Explained

Decimal format

Decimal entities use the character's Unicode code point in base 10:

<p>Copyright &#169; 2026</p>
<!-- Renders: Copyright © 2026 -->

The decimal value matches the number you find in Unicode charts — U+00A9 has decimal value 169.

Hexadecimal format

Hex entities use the code point in base 16, prefixed with x:

<p>Copyright &#xA9; 2026</p>
<!-- Renders: Copyright © 2026 -->

Hex format maps directly to the standard Unicode notation. U+00A9 becomes &#x00A9; — you simply drop the U+ prefix and add &#x ... ;.

When numeric is your only option

Most characters beyond the common symbols lack named entities:

CharacterNamedDecimalHexDescription
&#8800;&#x2260;Not equal
&#8804;&#x2264;Less than or equal
&#8805;&#x2265;Greater than or equal
&#8594;&#x2192;Right arrow
&#8592;&#x2190;Left arrow
&#8377;&#x20B9;Indian rupee
&#8381;&#x20BD;Russian ruble
&#8230;&#x2026;Ellipsis

If a character has no named entity, use decimal or hex. Both work identically in all modern browsers.

When to Use Which Format

ContextBest FormatReason
Core five (& < > " ')NamedMost readable, universally understood
Common symbols (©, €, —)NamedSelf-documenting in source code
Rare symbols, math, arrowsDecimal or hexNo named entity exists
Email templatesDecimalMost reliable across email clients
XML documentsNamed (limited) or decimalXML supports only 5 named entities
Dynamic output from JavaScriptHexMatches Unicode escape syntax (\uXXXX)

Readability comparison

<!-- Same character, three formats -->
<p>Price: &euro;49</p>
<p>Price: &#8364;49</p>
<p>Price: &#x20AC;49</p>

All three render identically, but the named version communicates intent fastest when reading source code.

Compatibility Notes

  • HTML4 supports roughly 250 named entities. HTML5 expanded this to over 2,000.
  • XML recognizes only five named entities: &amp;, &lt;, &gt;, &quot;, &apos;. Use numeric entities for everything else in XML.
  • &apos; was invalid in HTML4 but works in HTML5 and XML. Use &#39; for maximum compatibility.
  • Numeric entities work everywhere — HTML4, HTML5, XML, XHTML, and all browsers.
  • UTF-8 documents can often display characters directly without entities, but you still need entities for the core five to avoid parsing conflicts.

Character Sets and Encoding

Your document's character encoding determines how the browser interprets bytes before entity resolution occurs.

<!-- Always declare UTF-8 in your HTML -->
<meta charset="utf-8">

With UTF-8, you can safely paste most characters directly: ©, , . However, the characters <, >, &, ", and ' still require entities when they appear as data — your charset does not change their structural meaning in HTML.

Key Takeaways

  • Three entity formats exist: named (&amp;), decimal (&#38;), and hexadecimal (&#x26;)
  • Encode the core five characters (& < > " ') every time they appear as data
  • Named entities improve source readability; numeric entities offer full Unicode coverage
  • Use decimal entities for email templates and XML where named support is limited
  • UTF-8 charset lets you write most characters directly, but reserved characters always need entities
  • Always include the semicolon — omitting it creates parser ambiguity

Try It Yourself

Look up, encode, and decode HTML entities instantly with our free HTML Encoder/Decoder tool. Search by character or entity name and get all three formats at once.