Understanding HTML Entities

HTML character references provide a way to represent reserved characters, symbols, spaces, and other Unicode characters within an HTML document.

Some characters have special meaning in HTML or may be difficult to enter directly. Character references let you represent these characters using a named reference or a numeric Unicode value.

What Are HTML Entities?

The term HTML entity is commonly used for a named character reference such as © or &. More generally, HTML supports character references, which include both named and numeric forms.

A character reference begins with an ampersand (&) and normally ends with a semicolon (;). The browser interprets the reference and displays the corresponding character.

©

The browser displays:

©

Character references are especially useful when a character has a special purpose in HTML, cannot easily be typed from a keyboard, or is clearer when represented explicitly in the source code.

Named Character References

Named character references use predefined names that describe or identify particular characters. They begin with an ampersand and are followed by the character name and a semicolon.

©
®
&
<
>

These references display the copyright symbol (©), registered trademark symbol (®), ampersand (&), less-than sign (<), and greater-than sign (>).

Named references can make frequently used characters easier to recognize when reading HTML source code.

Numeric Character References

Numeric character references identify a Unicode character by its numeric value instead of using a predefined entity name. HTML supports both decimal and hexadecimal references.

Decimal Character References

A decimal character reference begins with &#, followed by the character's decimal Unicode value and a semicolon.

&#169;

The browser displays:

©

Hexadecimal Character References

A hexadecimal character reference begins with &#x, followed by the hexadecimal Unicode value and a semicolon.

&#xa9;

The browser displays:

©

Both examples represent the same Unicode character, so both display the copyright symbol.

Reserved Characters

Some characters have a special meaning in HTML syntax. When you need those characters to appear as text rather than be interpreted as markup, a character reference may be necessary.

Character Named Reference Decimal Hexadecimal
& &amp; &#38; &#x26;
< &lt; &#60; &#x3c;
> &gt; &#62; &#x3e;
" &quot; &#34; &#x22;
' &apos; &#39; &#x27;

The less-than sign is particularly important because HTML uses it to begin tags. For example, writing &lt;p&gt; in the source allows the browser to display <p> as text instead of interpreting it as markup.

Non-Breaking Space

A non-breaking space creates a space between characters while preventing the browser from breaking the line at that position. The named character reference is &nbsp;.

10&nbsp;GB

The browser displays:

10 GB

This can be useful when two pieces of text should remain together, such as a number and its unit, an initial and surname, or other short combinations that should not be separated by a line break.

Multiple Spaces in HTML

Browsers normally collapse consecutive ordinary spaces in HTML text into a single displayed space. Non-breaking spaces can create additional visible spacing, but they should not be used to control page layout.

First&nbsp;&nbsp;&nbsp;Second

Use CSS for margins, padding, alignment, and other visual spacing rather than inserting repeated &nbsp; references.

Common Symbols

Character references can represent many symbols that are useful in webpages, including copyright, trademark, currency, mathematical, and directional symbols.

Symbol Named Reference Decimal Hexadecimal
© &copy; &#169; &#xa9;
® &reg; &#174; &#xae;
&trade; &#8482; &#x2122;
&euro; &#8364; &#x20ac;
£ &pound; &#163; &#xa3;
¥ &yen; &#165; &#xa5;

For larger collections, use the Currency Symbols, Math Symbols, Arrows, and Other Symbols references.

Diacritical Marks

Diacritical marks are marks added to letters to indicate differences in pronunciation, stress, or meaning. Examples include acute accents, grave accents, circumflexes, tildes, umlauts, and cedillas.

Character Named Reference Decimal Hexadecimal
á &aacute; &#225; &#xe1;
è &egrave; &#232; &#xe8;
ô &ocirc; &#244; &#xf4;
ñ &ntilde; &#241; &#xf1;
ü &uuml; &#252; &#xfc;
ç &ccedil; &#231; &#xe7;

Modern UTF-8 documents can contain these characters directly, so you can normally type words such as café, piñata, or façade directly into the HTML source. Character references remain useful when you specifically need or prefer to represent the character by its Unicode value or named reference.

For additional characters, see the Latin Characters, Greek Characters, Cyrillic Characters, and other sections of the HTML Entity Reference.

Using Character References

Named, decimal, and hexadecimal references can represent the same character. Which form you use usually depends on readability and the character you need.

<p>Copyright &copy; 2026 Example Website</p>
<p>Copyright &#169; 2026 Example Website</p>
<p>Copyright &#xa9; 2026 Example Website</p>

All three copyright references display the same character. For common characters, a named reference such as &copy; can be easier to recognize, while numeric references can represent Unicode characters without requiring a named HTML reference.

Play in Editor

Best Practices

  • Use UTF-8 by including <meta charset="utf-8"> in the document head.
  • Use character references when a character could otherwise be interpreted as HTML markup.
  • Include the terminating semicolon when writing character references.
  • Use direct Unicode characters when they make the source easier to read and there is no reason to encode them as references.
  • Use CSS rather than repeated non-breaking spaces to control visual spacing and layout.
  • Use the HTML Entity Reference when you need to look up additional characters and symbols.

Summary

HTML character references provide named, decimal, and hexadecimal ways to represent characters in HTML. They are particularly useful for reserved HTML characters and can also represent spaces, symbols, accented characters, and other Unicode characters.

For most modern webpages, UTF-8 allows characters to be entered directly into the HTML source. Character references remain important when characters have special meaning in HTML or when representing a character explicitly makes the source clearer.