What are HTML entities?
In HTML, < starts a tag and & starts a character reference, so text that contains them has to write them another way. A character reference, often called an HTML entity, is an & followed by a name or a number and a semicolon. There are three kinds: named (©), decimal (©) and hexadecimal (©). All three give ©.
Quotes need encoding inside attribute values, so " becomes " and ' becomes '. Other characters can be typed as they are in a UTF-8 page; encode them too only for systems that carry plain ASCII.
Source WHATWG HTML Standard · 13.1.4 Character references ↗
How to encode and decode HTML entities
Here it is with your numbers:
- “<” (U+003C) becomes
<, 2 times. - “>” (U+003E) becomes
>, 2 times. - “&” (U+0026) becomes
&. - “'” (U+0027) becomes
'. - “"” (U+0022) becomes
", 2 times.
It means you can paste the result into HTML, and the page shows exactly what you typed.
Decoding works the other way, as a browser reads the page: it takes the longest name that matches, so ∉ is ∉ but ¬it; is ¬ followed by “it;”. Numbers 128 – 159 become the characters the old windows-1252 code page put there (€ is €), and 0, numbers past 10FFFF and the surrogate range become �.
Source WHATWG HTML Standard · 13.2.5.72 Character reference state ↗
HTML entity examples
| Character | Named | Decimal |
|---|---|---|
| & | & | & |
| < | < | < |
| > | > | > |
| " | " | " |
| ' | ' | ' |
| (no-break space) | |   |
| © | © | © |
| ™ | ™ | ™ |
| € | € | € |
| – | – | – |
| — | — | — |
| … | … | … |
| • | • | • |
Which named references this tool decodes
The HTML Standard lists 2,231 names, too many for this page to carry and stay fast. The decoder knows the 259 HTML 4 names (accented and Greek letters, arrows, maths and typography signs) plus ' and the capital forms &, <, >, ", © and ®. Every numeric reference works. Other names, like ✓, are left as typed and listed in the steps.
Source WHATWG HTML Standard · 13.5 Named character references ↗
FAQs
What is HTML entity encoding?
Writing a character as a character reference instead: an &, then a name or a number, then a semicolon, like < for <. The browser shows the character as text, so < and & in your text can’t be mistaken for HTML code.
What is ' in HTML?
' is the apostrophe ('): a decimal numeric reference to character 39. Written properly it ends in a semicolon, ', though browsers also accept it without one.
What is • in HTML?
• is the bullet (•), character U+2022. Its named reference is •.
Source WHATWG HTML Standard · 13.5 Named character references ↗
How can I decode HTML code?
Switch this tool to Decode and paste the text. Each &name; or &#number; becomes its character, using the same rules a browser follows, including the old forms without a semicolon.
Source WHATWG HTML Standard · 13.2.5.72 Character reference state ↗
What is %27 in HTML encoding?
%27 is URL (percent) encoding, not HTML: it is the apostrophe as byte 27 in hex, used in web addresses. In HTML the apostrophe is ' or '. Use the URL Encoder and Decoder for %27.
Source RFC 3986 · Uniform Resource Identifier (URI): Generic Syntax, section 2.1 ↗
Sources
- WHATWG HTML Standard: 13.1.4 Character references
- WHATWG HTML Standard: 13.2.5.72 Character reference state
- WHATWG HTML Standard: 13.5 Named character references
- RFC 3986: Uniform Resource Identifier (URI): Generic Syntax, section 2.1