HTML Entities
Some characters have a special job in HTML. The less-than sign < starts a tag and the ampersand & starts an entity, so if you simply type them into your text the browser may misunderstand you. Character entities are codes that stand for a character, letting you display it safely.
An entity starts with & and ends with ;. It can be written three ways:
| Form | Example for < |
|---|---|
| Named | < |
| Decimal number | < |
| Hexadecimal number | < |
Named entities are easier to remember; numeric ones work for any Unicode character.
Reserved characters
These are the characters you most often need to escape:
| Character | Entity | Name | When you must escape it |
|---|---|---|---|
< |
< |
less than | Always in text, to avoid starting a tag |
> |
> |
greater than | Recommended for symmetry |
& |
& |
ampersand | When followed by text that looks like an entity |
" |
" |
double quote | Inside a double-quoted attribute value |
' |
' |
apostrophe | Inside a single-quoted attribute value |
<!DOCTYPE html>
<html>
<body style="font-family: sans-serif">
<p>Typed raw: <b>bold?</b> — the browser made it a real tag.</p>
<p>Escaped: <b>bold?</b> — now it is shown as text.</p>
<p>Fish & Chips, 5 < 7, and a "quoted" word.</p>
<input value="She said "hello"" size="25">
</body>
</html>Non-breaking space
HTML collapses multiple spaces into one, and the browser may wrap a line at any space. The non-breaking space is a space that:
- never becomes a line break, so the words on either side stay together, and
- is not collapsed, so several in a row produce wider gaps.
Use it to keep things like 10 km, Mr. Smith or § 12 on the same line.
<!DOCTYPE html>
<html>
<head>
<style>
p { width: 150px; border: 1px dashed #aaa; font-family: sans-serif; }
</style>
</head>
<body>
<p>The race is exactly 42 km long, so pace yourself.</p>
<p>The race is exactly 42 km long, so pace yourself.</p>
<p>Spaces: many ordinary spaces collapse.</p>
<p>Spaces: kept wide.</p>
</body>
</html>In the first box, "42" and "km" may be split across lines; in the second they never are.
Tip: Don't use rows of
for layout or indentation. Use CSS margins and padding instead — is for keeping words together.
Other useful named entities
| Result | Entity | Description |
|---|---|---|
| © | © |
copyright |
| ® | ® |
registered trademark |
| ™ | ™ |
trademark |
| € | € |
euro |
| £ | £ |
pound |
| ¥ | ¥ |
yen |
| ° | ° |
degree |
| × | × |
multiplication |
| ÷ | ÷ |
division |
| – | – |
en dash (ranges: 9–5) |
| — | — |
em dash |
| … | … |
ellipsis |
| « » | « » |
angle quotes |
| → | → |
right arrow |
<!DOCTYPE html>
<html>
<body style="font-family: sans-serif; line-height: 1.8">
<p>© 2026 Sunny Shop™ — all rights reserved.</p>
<p>Price: 19.99 € | Oven: 180°C</p>
<p>Open Mon–Fri, 9–17 → see you soon…</p>
<p>3 × 4 = 12 and 12 ÷ 4 = 3</p>
</body>
</html>Diacritics and combining marks
Accented letters such as é or ñ can be typed directly when the page uses UTF-8 (which it should — see the Charset lesson). Numeric entities and combining marks also work: a combining character modifies the letter before it.
<!DOCTYPE html>
<html>
<body style="font-family: sans-serif; font-size: 22px">
<p>Direct: café, señor, Ångström</p>
<p>Named: café, señor, Ångström</p>
<p>Combining marks: á õ ë (a + acute, o + tilde, e + diaeresis)</p>
</body>
</html>Note: Entity names are case-sensitive:
Åis Å whileåis å. If an entity name is misspelled, the browser just shows the raw text, such as©y;.
Test yourself
Which entity displays a less-than sign <?
<<&less;&#lt;
What is special about ?
- It is invisible and takes no space
- It is a space the browser will not break a line at or collapse
- It starts a new paragraph
- It adds a tab character
How would you write the copyright sign using a named entity?
©right;&c;©(c)