What is HTML Entity?

HTML Entity (HTML Character Entity) is a string that begins with an ampersand (&) and ends with a semicolon (;), used to represent special characters in HTML that would otherwise be interpreted as HTML code or are not easily typed on a keyboard.

Quick Facts

Full NameHTML Character Entity
Created1993 (with HTML specification)
SpecificationOfficial Specification

How It Works

HTML entities allow web developers to display reserved characters like <, >, &, and " that have special meanings in HTML markup. They also enable the display of characters not available on standard keyboards, such as copyright symbols (©), mathematical symbols (±), and characters from other languages. Entities can be written as named references (like &amp;) or numeric references using decimal (&#38;) or hexadecimal (&#x26;) codes. The HTML5 specification defines over 2,000 named character references.

Key Characteristics

  • Starts with & and ends with ; (e.g., &amp;)
  • Named entities use descriptive names (e.g., &copy;)
  • Numeric entities use decimal (&#169;) or hex (&#xA9;) codes
  • Required for displaying reserved HTML characters
  • Case-sensitive for named entities
  • Over 2,000 named entities defined in HTML5

Common Use Cases

  1. Displaying HTML reserved characters (<, >, &, ", ')
  2. Inserting special symbols (©, ®, ™, €)
  3. Adding non-breaking spaces (&nbsp;)
  4. Displaying mathematical symbols (±, ×, ÷)
  5. Including characters from other languages

Example

loading...
Loading code...

Frequently Asked Questions

What is the difference between named and numeric HTML entities?

Named entities use descriptive words (like &copy; for ©), making them easier to remember and read. Numeric entities use decimal (&#169;) or hexadecimal (&#xA9;) codes. Named entities are limited to those defined in the HTML specification, while numeric entities can represent any Unicode character.

When should I use HTML entities instead of typing characters directly?

Use HTML entities for: 1) Reserved HTML characters (<, >, &, ", ') that would be interpreted as markup, 2) Characters not available on your keyboard, 3) When you need consistent rendering across all systems regardless of character encoding, 4) Non-breaking spaces (&nbsp;) for layout control.

Are HTML entities case-sensitive?

Yes, named HTML entities are case-sensitive. For example, &copy; (©) is valid, but &COPY; may not render correctly in all browsers. Numeric entities (both decimal and hexadecimal) are not case-sensitive for the 'x' prefix, so &#xA9; and &#Xa9; are equivalent.

How do I display an ampersand (&) in HTML without it being interpreted as an entity?

Use the &amp; entity to display a literal ampersand. Writing just & in HTML can cause parsing issues because the browser may interpret it as the start of an entity. For example, to show 'Tom & Jerry', write 'Tom &amp; Jerry' in your HTML code.

What is the &nbsp; entity and when should I use it?

&nbsp; represents a non-breaking space. It prevents line breaks between words and preserves multiple spaces (browsers normally collapse consecutive spaces into one). Use it for: keeping phone numbers together (555&nbsp;123&nbsp;4567), preventing breaks between values and units (100&nbsp;km), or forcing visible spaces in your layout.

Related Tools

Related Terms

Related Articles