Tutorials
THE WORLD'S LARGEST WEB DEVELOPER SITE

HTML Entities

Reserved characters in HTML should be replaced by character entities.

inclusion of Characters which are not present on your keyboard can also be done using entities.

HTML Entities

 

In HTML, Some characters are kept reserved .

when you are using the less than (<) or greater than (>) signs in your text, the browser can possibily mix them with tags.

Character entities are utilised for displaying reserved characters in HTML.

A character entity will appear like this:

&entity_name;

OR

&#entity_number;

for displaying a less than sign (<) we must write: < or <

entity name usage advantage:remembering an entity name is easy.
entity name disadvantage: few browsers may or may not support all entity names, but the support for numbers is good.

Non-breaking Space

 

A common character entity which is predominantly used in HTML is the non-breaking space: &nbsp;

A non-breaking space can be said as a space which will not be breaking into a new line.

Two words that are separated using a non-breaking space will stick together (i.e not break into a new line). This is useful and handy while breaking the words might become disruptive.

Examples:

Another common usage of the non-breaking space is prevention of browsers for truncating spaces in HTML pages.

If you are using 10 spaces in your text, 9 of them will be removed by the browser.For adding real spaces to your text, usage of &nbsp; character entityis helpful.

The non-breaking hyphen (‑) allows you to use a hyphen character (‑) which won't break.

Some Other Useful HTML Character Entities

 
Result Description Entity Name Entity Number
non-breaking space &nbsp; &#160;
< less than &lt; &#60;
> greater than &gt; &#62;
& ampersand &amp; &#38;
¢ cent &cent; &#162;
£ pound &pound; &#163;
¥ yen &yen; &#165;
euro &euro; &#8364;
© copyright &copy; &#169;
® registered trademark &reg; &#174;

case sensitivity is applicable to entity names.

Combination of Diacritical Marks

 

A diacritical mark can be called as a "glyph" which is added to a letter.

Some of the diacritical marks, such as grave ( ̀) and acute ( ́) are called accents.

Diacritical marks can be appearing at both above and below a letter or inside a letter or in-between two letters.

combinations of diacritical marks can also be utilised in combination, to produce a character that is not present in the character set (encoding) used in the page.

you can see some examples here:

Mark Character Construct Result
 ̀ a a&#768;
 ́ a a&#769;
̂ a a&#770;
 ̃ a a&#771;
 ̀ O O&#768;
 ́ O O&#769;
̂ O O&#770;
 ̃ O O&#771;

We can see more of HTML symbols in the following chapter of this tutorial.