HTML entities: &, <,  , © and numeric references
verified onenvironmentlocal · windows 10.0.26200 arm64 · GNU bash 5.3.15 (Git Bash)updated 2026-10-20
- tool
- HTML
- versions
- HTML Living Standard
- os
- any
An HTML entity (character reference) writes a character as &name;, &#decimal; or &#xhex;. Five characters need escaping in HTML text or attributes because they are part of the syntax: & as &, < as <, > as >, and inside attributes " as " and ' as '. Everything else can be typed directly in a UTF-8 page.
Must-escape characters
| Character | Entity | Numeric | Why |
|---|---|---|---|
| & | &amp; | &#38; | starts every entity |
| < | &lt; | &#60; | starts a tag |
| > | &gt; | &#62; | ends a tag (escape for symmetry) |
| " | &quot; | &#34; | ends a double-quoted attribute |
| ' | &#39; (or &apos;) | &#39; | ends a single-quoted attribute |
Frequently used entities
| Entity | Character | Name |
|---|---|---|
| &nbsp; | (no-break space) | U+00A0 |
| &copy; | © | copyright |
| &reg; / &trade; | ® / ™ | registered, trade mark |
| &euro; / &pound; | € / £ | currencies |
| &mdash; / &ndash; | — / – | dashes |
| &hellip; | … | ellipsis |
| &laquo; / &raquo; | « / » | angle quotes |
| &times; / &divide; | × / ÷ | multiplication, division |
| &rarr; / &larr; | → / ← | arrows |
Encode and decode them
PYTHONIOENCODING=utf-8 python -c '
import html
print(html.escape("<a href=\"/q?x=1&y=2\">Tom & Jerry</a>"))
print(html.unescape("© 2026 — café ✓ €"))'Output
<a href="/q?x=1&y=2">Tom & Jerry</a> © 2026 — café ✓ €
html.escape escapes quotes by default (quote=True), so its output is safe in attribute values as well as text.
Sources
Related pages
cheat sheets · cssCSS flexbox cheat sheet: container and item propertiesCSS flexbox cheat sheet: display flex, flex-direction, justify-content, align-items, flex-wrap and gap on the container; flex, align-self, order on items.compat · cssCSS :has() browser supportCSS :has() works in Chrome and Edge 105+, Safari 15.4+ and Firefox 121+, per MDN browser-compat-data. Feature-detect it with @supports selector(:has(a)).errors · jsonSyntaxError: Unexpected token '<', "<!DOCTYPE "... is not valid JSONJSON.parse fails with Unexpected token '<' when the response is an HTML page, usually an error or login page, not JSON. Check the status and content type first.