HTML Entities

0
1102
HTML Entities

In HTML there is a special meaning for some characters like the < character and cannot be used in the text. We have to use a character entity to display a less than sign in HTML.

Character Entities

In HTML some characters have a special meaning by defining the start of an HTML tag by less than sign (<). We have to insert character entities in the HTML source if want to display actual characters in the browser.

There are three parts of a character: an ampersand (&), an entity name or a # and an entity number, and  a semicolon finally.

We must write &lt; or &#60; to display a less than sign in HTML document. The name is used instead of a number because a name is easier to remember. The newest entity names are not supported by all the browsers. In almost all browsers the support for entity numbers is very good and the entities are case sensitive.

Non-Breaking Space

The non-breaking space is the most common entity in HTML. To truncate spaces in your text HTML is used normally. HTML will remove 9 spaces if you write 10 spaces in your text. Use the &nbsp; character entity to add spaces to your text.

The Most Common Character Entities

Character(s) Literal(s) Alphanumeric value(s) Unicode value(s) Prefer to
Cent (currency) ¢ &cent; &#162;  
Pound (currency) £ &pound; &#163;  
Section 1 § &sect; &#167;  
Copyright © &copy; &#169; (c)
Guillemets 2 « » &laquo; &raquo; &#171; &#187; &quot;

Some Other Commonly Used Character Entities

Character(s) Literal(s) Alphanumeric value(s) Unicode value(s) Prefer to
Cent (currency) ¢ &cent; &#162;  
Pound (currency) £ &pound; &#163;  
Section 1 § &sect; &#167;  
Copyright © &copy; &#169; (c)
Guillemets 2 « » &laquo; &raquo; &#171; &#187; &quot;
SHARE
Previous articleHTML Colors
Next articleHTML Formatting