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.
>. 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.
Below are some examples of some popular HTML entities.
|™||TRADE MARK SIGN|
|✩||STRESS OUTLINED WHITE STAR|
|✪||CIRCLED WHITE STAR|
|❞||HEAVY DOUBLE COMMA QUOTATION MARK ORNAMENT|
|❤||HEAVY BLACK HEART|
|▶||BLACK RIGHT-POINTING TRIANGLE|
|▽||WHITE DOWN-POINTING TRIANGLE|
|℗||SOUND RECORDING COPYRIGHT|
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 use letters to specify which entity to use.
© 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