Some characters have a special meaning in HTML, like the less than sign (<) that defines the start of
an HTML tag. If we want the browser to actually display these characters we must insert character
entities in place of the actual characters themselves.
The Most Common Character Entities:
Result Description Entity Name Entity Number
< less than < <
> greater than > >
& ampersand & &
" quotation mark " "
' apostrophe ' (does not work in IE) '
A character entity has three parts: an ampersand (&), an entity name or an entity number, and finally
a semicolon (;). The & means we are beginning a special character, the ; means ending a special
character and the letters in between are sort of an abbreviation for what it’s for. To display a less than
sign in an HTML document we must write: < or < The advantage of using a name instead of a
number is that a name is easier to remember. The disadvantage is that not all browsers support the
newest entity names, while the support for entity numbers is very good in almost all browsers.
Note: Entities are case sensitive.
The most common character entity in HTML is the non-breaking space . Normally HTML will
truncate spaces in your text. If you add 10 spaces in your text, HTML will remove 9 of them. To add
spaces to your text, use the character entity.
<p> This code would appear
as this.</p> Would Display This code would appear as this.
<p> This code would
appear with three extra spaces.</p> Would Display
This code would appear with three extra