HTML entities
There is so much text on so many webpages across the web, and some of this text happens to be special characters that do not appear on a keyboard. How then, to go about including such characters on webpages?
This tutorial focuses on:
- What is an entity?
- Entity construction
- Common entities
- Reverse entities
What is an entity?
An entity is a symbol that is displayed on a webpage such as the copyright symbol ( � ), the trademark symbol (�), and the ampersand symbol (&). Each entity is displayed using a special code.
Entity construction
Now that you what entities are, how do you go displaying them?
An HTML entity code has three parts:
- An ampersand ( & )
- An entity name or a # sign and an entity number
- A semicolon ( ; )
For example, to display a greater than sign on a webpage, we would write > or >
Here it is again - >
NOTE: While you can use names or numbers for character entities, it is better to use names because they are easier to remember.
NOTE: Entities are case sensitive!
Common entities
There are many entities you can use, the ones below are very commonly used.
Common character entities and what they will display:
Entity Name | Entity Number | Character | Output |
---|---|---|---|
|   | space | |
< | < | less than sign | < |
> | > | greater than sign | > |
& | & | ampersand | & |
" | " | quotation mark | " |
' | " | apostrophe | ' |
© | © | copyright symbol | � |
® | ® | trademark symbol | � |
× | × | multiplication symbol | x |
÷ | ÷ | division symbol | � |
For a full list of HTML character entities, read our HTML character entities reference page.
Read more about text formatting in our HTML text formatting 1, HTML text formatting 2, and HTML text formatting 3 tutorials.
Reverse entities
What if you wanted to print the code for an entity on a webpage instead of the character itself?
Remember that every entity begins with the & symbol, and how do we display this symbol? By using the & entity. So to display the code for an entity on a webpage instead of the character itself, simply use & to produce an & symbol followed by the rest of the entity code.