HTML Entities
HTML entities are codes that represent characters which would otherwise be interpreted as markup — like < or & — or which can't be typed easily.
Most-used entities
| Entity | Renders as | Use for |
|---|---|---|
< | < | Less-than sign — when writing about HTML tags. |
> | > | Greater-than sign. |
& | & | Ampersand — escape inside attribute values too. |
" | " | Double quote inside an attribute. |
' | ' | Single quote inside an attribute. |
| (non-breaking space) | Glue two words so the browser doesn't break the line between them. |
© | © | Copyright symbol. |
® | ® | Registered trademark. |
— | — | Em dash. |
… | … | Ellipsis. |
Numeric entities
Any Unicode character can be written as a numeric entity:
- Decimal:
☃renders ☃ (snowman). - Hex:
☃renders ☃ (same snowman).
Tip: If the page is UTF-8 (it should be), you can paste most special characters directly into the source instead of escaping them.
Example
Example
<!DOCTYPE html>
<html>
<head>
<title>HTML Entities</title>
</head>
<body>
<h1>HTML Entities</h1>
<p>This is a demo page for the "HTML Entities" lesson.</p>
</body>
</html>
Try it Yourself »
Exercise
Write the entity for the less-than sign so it renders as text.
<p>If a
b then…</p>
Starts with < … ends with a semicolon.
Discussion
Loading…