HTML Character Entities

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:

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: &lt; or &#60; 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.
Non-breaking Space
The most common character entity in HTML is the non-breaking space &nbsp;. 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 &nbsp; character entity.
This Code
<p> This code would appear
as this.</p> Would Display This code would appear as this.
This Code
<p> This code &nbsp;&nbsp;&nbsp; would
appear with three extra spaces.</p> Would Display
This code would           appear with three extra

Share This:

Leave a Reply

Your email address will not be published. Required fields are marked *