A brief introduction to the concept of HTML entities.
HTML entities (also known as character entity references) enable you to add a wide range of characters to an HTML document. Characters ranging from icons, mathematical operators, geometric shapes, arrows, multilingual scripts, and much more, can be displayed in a web page by adding a small line of text.
For example, you can add a copyright symbol to a web page by typing
©
. You could also use its Unicode hexadecimal value (©
) or decimal value (©
) if you prefer.
Another important example is the less-than and greater-than signs (i.e.
<
and >
. These signs have special meaning in HTML documents. When the browser sees them it thinks it's an HTML tag and tries to interpret it as such.
If one day you actually wanted to display a greater-than sign on your webpage, you would need to use the HTML entity (or one of the numeric values). So, you could type
>
and it will be displayed to your users instead of being interpreted by the browser.Entity Examples
Below are some examples of some popular HTML entities.
Character | Entity | Hexadecimal | Decimal | Name |
---|---|---|---|---|
© | © © | © | © | COPYRIGHT SIGN View in Editor |
® | ® ® ® | ® | ® | REGISTERED SIGN View in Editor |
™ | ™ ™ | ™ | ™ | TRADE MARK SIGN View in Editor |
> | > > | > | > | GREATER-THAN SIGN View in Editor |
< | < < | < | < | LESS-THAN SIGN View in Editor |
; | ; | ; | ; | SEMICOLON View in Editor |
& | & & | & | & | AMPERSAND View in Editor |
" | " " | " | " | QUOTATION MARK View in Editor |
# | # | # | # | NUMBER SIGN View in Editor |
★ | ★ ★ | ★ | ★ | BLACK STAR View in Editor |
☆ | ☆ | ☆ | ☆ | WHITE STAR View in Editor |
✂ | ✂ | ✂ | BLACK SCISSORS View in Editor | |
✓ | ✓ ✓ | ✓ | ✓ | CHECK MARK View in Editor |
✗ | ✗ | ✗ | ✗ | BALLOT X View in Editor |
✩ | ✩ | ✩ | STRESS OUTLINED WHITE STAR View in Editor | |
✪ | ✪ | ✪ | CIRCLED WHITE STAR View in Editor | |
❞ | ❞ | ❞ | HEAVY DOUBLE COMMA QUOTATION MARK ORNAMENT View in Editor | |
❤ | ❤ | ❤ | HEAVY BLACK HEART View in Editor | |
← | ← ← ← ← ← | ← | ← | LEFTWARDS ARROW View in Editor |
↑ | ↑ ↑ ↑ ↑ | ↑ | ↑ | UPWARDS ARROW View in Editor |
→ | → → → → → | → | → | RIGHTWARDS ARROW View in Editor |
↓ | ↓ ↓ ↓ ↓ | ↓ | ↓ | DOWNWARDS ARROW View in Editor |
€ | € | € | € | EURO SIGN View in Editor |
▶ | ▶ | ▶ | BLACK RIGHT-POINTING TRIANGLE View in Editor | |
▽ | ▽ ▽ | ▽ | ▽ | WHITE DOWN-POINTING TRIANGLE View in Editor |
◉ | ◉ | ◉ | FISHEYE View in Editor | |
∑ | ∑ ∑ | ∑ | ∑ | N-ARY SUMMATION View in Editor |
ℹ | ℹ | ℹ | INFORMATION SOURCE View in Editor | |
№ | № | № | № | NUMERO SIGN View in Editor |
℗ | ℗ | ℗ | ℗ | SOUND RECORDING COPYRIGHT View in Editor |
℃ | ℃ | ℃ | DEGREE CELSIUS View in Editor | |
℉ | ℉ | ℉ | DEGREE FAHRENHEIT View in Editor |
For a longer list of HTML entities, see this extensive list of Unicode characters.
How to Reference an Entity
You can reference an entity either by its name, or by a numeric character reference.
Each method begins with an ampersand (
&
) and ends with a semicolon (;
), but the part in the middle is different.Entity Names
Entity names use letters to specify which entity to use.
So
©
is an example of using the entity name.
However, not all Unicode characters have a corresponding entity name (as you can see in the above list). However, all Unicode characters are assigned a hexadecimal number which is unique to that character. So if you don't see an entity name for a character, use the hexadecimal or decimal value instead.
Numeric Character References
You can also use numeric character references to write character entities (as seen by the examples above).
Numeric character references include a hash (
#
) after the ampersand, followed by some numbers, and ending with a semicolon (;
).
Numeric character references can be defined with either a decimal or hexadecimal value. The numeric character reference for the copyright symbol is
©
(decimal) and ©
(hexadecimal).