HTML Entities Explained: & and Beyond

HTML Entities Explained: & and Beyond

&amp; isn’t a typo — it’s how HTML writes the ampersand itself. The < and & characters are structural in HTML, so writing them literally breaks the page; entities are the escape hatch.

Why entities exist

HTML uses < and > to mark tags and & to start entities. To display these characters as text, you encode them:

Character Entity
& &amp;
< &lt;
> &gt;
" &quot;
non-breaking space &nbsp;

Forget to encode and the results are memorable: a bare & swallows the text after it, a bare < can eat an entire page section.

Named vs numeric

  • Named entities (&amp;, &copy;): readable, but limited to a few hundred characters.
  • Numeric codes (&#169;, &#x4E2D;): decimal or hex Unicode points — cover every character in existence, at the cost of readability.

The two tools handle each half: the HTML entity encoder/decoder converts between characters and their entities, and the entity to Unicode converter translates numeric codes back into readable characters.

When you’ll meet entities

  • Writing content that mentions HTML — every tutorial about code embeds entities.
  • Copy-pasting into forms: the &nbsp; you didn’t see from a rich-text editor is the classic “why is there a weird space” answer.
  • Non-Latin text in old systems: a Chinese character such as &#x4E2D; where UTF-8 wasn’t supported.

Entities are the oldest compatibility layer on the web — clunky, but still doing their job everywhere HTML exists.