About HTML Entities
What is an HTML entity?
An HTML entity is a code, such as &, that a browser replaces with the character it stands for.
The HTML standard calls it a character reference and allows three forms. The name ©, the decimal number © and the hexadecimal number © all give the same ©.
HTML defines 2,231 entity names for 1,511 different characters. A numeric reference can stand for almost any Unicode character, so a character with no name can still be written as a number.
- Older names without a semicolon. Of the 2,231 names, 2,125 end in a semicolon. The other 106 are older names written without it, such as
©, and each one also exists with the semicolon.
- Two code points in one name. Of the 1,511 characters, 65 are pairs of code points, and 93 names stand for them, such as
≂̸ for ≂̸, a minus tilde with a slash through it.
- Case-sensitive names.
Δ gives Δ, δ gives δ, and Δ is not a name.
- Several names, one character. A character can have up to six names. Only the almost-equal sign ≈ has six, including
≈ and ≈.
When should you use HTML entities?
Use a character reference when a character would otherwise be read as markup.
In text, write < for < and & for &. Inside a double-quoted attribute value, write & for & and " for ". On a page saved as UTF-8, almost every other character can be typed as itself.
References still help with characters you can't see or easily type, such as the no-break space ( ) or the zero width space (​). They also keep characters intact when text passes through a system that doesn't use UTF-8.
How to write a character reference
- Search the list by name, character or code point, such as rarr, → or U+2192.
- Click the character to copy its entity name. Its decimal and hex references appear in the Selected character panel, ready to copy.
- Paste it into your HTML, and keep the semicolon at the end.
- Check the page. If the code itself shows up, the name is misspelled, the semicolon is missing, or the text was escaped twice.
Example
The input text will be converted to escaped HTML by the rules in the HTML standard. Browsers use the same rules when they turn a page back into markup, for example when a script reads innerHTML.
Q&A: 5 < 6 and 7 > 4 in "Tom's" notes
Q&A: 5 < 6 and 7 > 4 in "Tom's" notes
Q&A: 5 < 6 and 7 > 4 in "Tom's" notes
The first output line is for text between tags, and the second is for a double-quoted attribute value. The apostrophe needs no reference in either line. A bare > is valid in both lines, and a bare < is valid in the attribute value, though browsers write them as > and <.
Our HTML entity encoder escapes a whole block of text at once.
What is the entity for a space, an apostrophe or an arrow?
A normal space has no entity name, and is a different character, the no-break space.
The table lists characters people often search for. The cloud ☁ has no entity name, so its reference has to be a number, such as ☁.
Named and numeric references for commonly searched characters
| Character | What it is | Named reference | Decimal |
| & | Ampersand | & | & |
| < | Less-than sign | < | < |
| > | Greater-than sign | > | > |
| " | Quotation mark | " | " |
| ' | Apostrophe | ' | ' |
| NBSP | No-break space | |   |
| · | Middle dot | · | · |
| . | Period | . | . |
| • | Bullet | • | • |
| ✓ | Check mark | ✓ | ✓ |
| → | Rightwards arrow | → | → |
| ← | Leftwards arrow | ← | ← |
| $ | Dollar sign | $ | $ |
| ? | Question mark | ? | ? |
| © | Copyright sign | © | © |
| ° | Degree sign | ° | ° |
| ☁ | Cloud | None | ☁ |
Should you use a name, a number or the character itself?
Type the character itself unless it is markup or invisible.
A UTF-8 page can hold almost any character directly, which keeps the source readable. Names are easier to read than numbers, but only 1,511 characters have one.
Four ways to write the copyright sign in HTML
| Way | Example | Works for | Best for |
| The character | © | Almost every character, on a page saved as UTF-8 | Most text, because the source stays readable |
| Named reference | © | The 1,511 characters that have a name | Markup characters such as & and <, and invisible ones such as the no-break space |
| Decimal reference | © | Almost every Unicode character | Characters with no name, when you know the decimal number |
| Hexadecimal reference | © | Almost every Unicode character | Characters with no name, when you know the hex code point |
Common mistakes
Each of these mistakes shows the wrong text on the page or breaks the HTML standard's rules.
- Leaving out the semicolon. Without it, only numeric references and 106 older names, such as
©, still work. In text, ¬in shows as ¬in instead of ∉, because browsers read the older name ¬ at its start.
- Escaping text twice.
&copy; shows "©" instead of ©. This happens when a template escapes text that is already escaped, so escape it once, when you output it.
- Copying codes from old Windows text.
– and ’ come from the Windows-1252 code page. Browsers turn them into – and ’, but the HTML standard counts them as parse errors, so write – and ’.
Where do the entity names come from?
The names come from the named character references table in the HTML standard, maintained by WHATWG.
We built the list from entities.json, the standard's machine-readable copy of that table, and took the character names from Unicode 18.0. A name that is missing from the named character references table does not work in HTML.
The MDN glossary says "HTML entity" is another name for a character reference.
Frequently Asked Questions
What does ' mean in HTML?
' is the apostrophe ('), code point U+0027, written as a decimal reference. The current HTML standard also names it ', which HTML 4 did not define.
Are entity names case-sensitive?
Yes, entity names are case-sensitive. Α gives Α, α gives α, and &ALPHA; is not a name at all.
Does a character reference need the semicolon?
Yes, always end a reference with a semicolon. Without it, browsers still read numeric references such as © and 106 older names such as ©, but the HTML standard counts that as a parse error.
Do entity names work in JavaScript strings?
No, JavaScript leaves © in a string as six plain characters. Write the escape \u00A9 instead, or assign the text to innerHTML when you want HTML to parse it.
Do entity names work in React JSX?
Only some do. In JSX text, Babel and esbuild decode numeric references, ' and the HTML 4 names such as ©, while newer names such as ✓ stay as plain text.
How many named character references does HTML have?
HTML defines 2,231 names. Many characters have more than one name, so the 2,231 names cover only 1,511 characters.
What is the difference between and a normal space?
is U+00A0, a no-break space that keeps the words on either side on one line. A normal space, U+0020, can break a line, and by default browsers collapse several of them into one.