Some characters are reserved in HTML. If you use the less than (<) or greater than (>) signs in your text, the browser might mix them up with a tag.
Character entities are used to display reserved characters, and other characters that are missing from a keyboard.
<p>I am 10 < 20 and 5 > 1.</p>The output looks like this:
I am 10 < 20 and 5 > 1.
| Result | Description | Entity Name |
|---|---|---|
| < | less than | < |
| > | greater than | > |
| & | ampersand | & |
| " | double quotation mark | " |
| (space) | non-breaking space | |
| © | copyright | © |
An entity name is often easier to remember than a number, but a browser may not support all entity names, while support for numbers is much better.
Where this comes up most
Use whenever you need a space the browser won't collapse — see the next lesson for why plain spaces get collapsed in the first place.