|
There are some characters in HTML that have a special meaning to an HTML document and can't be used
as text. For example we use < and > to start and end HTML tags. When we use these characters
we run into the problem we see below.
| This HTML Code |
Produces This |
|
<This will not display>
|
|
The browser is expecting an HTML tag to be within the < and >. Since the browser does not display what is contained between
< and > nothing is displayed.
At the same time you are noticing that we have been able to display < and > in the sentences describing how we
can have issues with < and >. We have used character entities to display < and > in the HTML source code.
The character entity for < is < or <
For > is > or >
|
A character entity has three parts: an ampersand (&), an entity name ( lt or gt in our case) or a # and an entity number ( 60 or 62 in our example)
and finally a semicolon (;).
Another issue is spacing of text. For example;
| This HTML Code |
Produces This |
|
This is 4 spaces apart
|
This is 4 spaces apart
|
In our text editor we wrote "This" and then we added 4 spaces before writing "is 4 spaces apart". However,
you will notice that when the HTML is shown in the brower there is only one space between "This" and "is".
The reason is that HTML generally cuts down or truncates spaces to one space.
To get around this we use the non-breaking space entity
| This HTML Code |
Produces This |
|
This is 4 spaces apart
|
This is 4 spaces apart
|
Here are some more commonly used character entities.
| Result |
Description |
Entity Name |
Entity Number |
| |
non-breaking space |
|
  |
| < |
less than |
< |
< |
| > |
greater than |
> |
> |
| & |
ampersand |
& |
& |
| " |
quotation mark |
" |
" |
| ¢ |
cent |
¢ |
¢ |
| £ |
pound |
£ |
£ |
| ¥ |
yen |
¥ |
¥ |
| € |
euro |
€ |
€ |
| § |
section |
§ |
§ |
| © |
copyright |
© |
© |
| ® |
registered trademark |
® |
® |
| × |
multiplication |
× |
× |
| ÷ |
division |
÷ |
÷ |
|