Some characters have special meaning in HTML — like < and > which define tags. If you type them directly as content, the browser misreads them. HTML entities are the safe way to display these characters, along with accented letters, symbols, and non-breaking spaces.
An HTML entity is a short code that represents a character. Every entity starts with & and ends with ;. There are two forms:
& for && for &Both produce the same result. Named entities are easier to remember; numeric entities cover every Unicode character.
<p>5 < 10 and 10 > 5</p>
<!-- Renders as: 5 < 10 and 10 > 5 -->
These four must always be escaped when used as content, because they’re part of HTML syntax.
| Character | Named entity | Numeric entity | When to use |
|---|---|---|---|
< | < | < | Less-than sign, opening angle bracket |
> | > | > | Greater-than sign, closing angle bracket |
& | & | & | Ampersand — always escape in content |
" | " | " | Double quote inside an attribute value |
<!-- Displaying code in prose -->
<p>The <p> tag creates a paragraph.</p>
<!-- Ampersand in text -->
<p>Terms & conditions apply.</p>
<!-- Quote inside an attribute -->
<p title="He said "hello"">Hover over me.</p>
Beyond the essential four, entities let you display typographic and mathematical symbols that are awkward to type or unsafe to paste directly.
| Symbol | Named entity | Description |
|---|---|---|
| © | © | Copyright |
| ® | ® | Registered trademark |
| ™ | ™ | Trademark |
| € | € | Euro sign |
| £ | £ | Pound sterling |
| ¥ | ¥ | Yen |
| ° | ° | Degree symbol |
| × | × | Multiplication sign |
| ÷ | ÷ | Division sign |
| → | → | Right arrow |
| ← | ← | Left arrow |
| ♥ | ♥ | Heart suit |
| … | … | Ellipsis |
| — | — | Em dash |
| – | – | En dash |
<p>© 2026 My website. All rights reserved.</p>
<p>Temperature today: 22°C</p>
<p>Price: £14.99 or €16.99</p>
The most commonly used entity is — a non-breaking space. Unlike a regular space, it prevents the browser from wrapping a line at that point, and it won’t collapse with adjacent spaces.
<!-- Prevent line break between number and unit -->
<p>The file is 4 MB in size.</p>
<!-- Keep a name together on one line -->
<p>Contact us for more details.</p>
Caution: don’t use
to create visual spacing or indentation. That’s CSS’s job. Use it only to prevent unwanted line breaks or to force a space in contexts where regular spaces collapse (like inside table cells or certain inline elements).
Modern HTML files saved with UTF-8 encoding (declared with <meta charset="UTF-8">) can include accented and international characters directly — you can type é, ü, ñ, 中, or العربية straight into your HTML without needing entities.
<!-- These are equivalent in UTF-8 HTML -->
<p>Café</p>
<p>Café</p>
<!-- Direct Unicode is cleaner and more readable -->
<p>Zürich, Montréal, España</p>
Use entities for accented characters only when you’re working in an environment that doesn’t support UTF-8, or when you need to be certain the character survives copy-paste between systems.
<body>
<h1>Special characters demo</h1>
<p>The <img> tag embeds images.</p>
<p>5 × 4 = 20 & 20 ÷ 4 = 5</p>
<p>Temperature: 37°C</p>
<p>File size: 2.4 GB</p>
<p>© 2026 My website — all rights reserved.</p>
<p>Price: £9.99 (€11.49)</p>
<p>Direct Unicode: Montréal, Zürich, España</p>
</body>
| Entity | Character | Description |
|---|---|---|
< | < | Less-than / open tag |
> | > | Greater-than / close tag |
& | & | Ampersand |
" | " | Double quote |
| (space) | Non-breaking space |
© | © | Copyright |
® | ® | Registered trademark |
™ | ™ | Trademark |
€ | € | Euro |
£ | £ | Pound sterling |
° | ° | Degree |
— | — | Em dash |
… | … | Ellipsis |
× | × | Multiplication |