HTML Lesson 12: Using Character Entity References

Share on FacebookShare on Google+Tweet about this on TwitterShare on LinkedInShare on RedditEmail this to someone

[Lesson 11]<<[Contents]>>[Lesson 13]

A webpage basically can be created using the HTML elements. However, certain characters cannot be typed directly into an HTML document because these characters are reserved for use as HTML elements. The most obvious examples are the > and < signs, they are reserved for the start tags and end tags of the HTML elements.  To overcome the issue, HTML provides character entity reference in the form of &code;. For example, to show the > sign on the webpage, we use &lt;  and for  the & sign, we use &amp;

The following table shows a list of characters and the respective HTML encoding.

Character

HTML code

> &gt;
< &lt;
&le;
&ge;
& &amp;
 spacing &nbsp;
½ &frac12;
¼ &frac14;
© &#169;
® &#174;
» &#187;
Ç &#199;
À &#192;
&#8482;
È &#200;
â &#226;
ß &#223;
Ģ &#290;
÷ &#247;

Example

If volume &gt; 100,000 and Price &lt; $50,000 then buy more. However, if volume &le;50,000, then stop trading. The earnings at volume=100000 is &frac14; of the total sales. HTML Tutorial &#174;is a registered trademark.The above article is &#169; Dr.Liew &amp; Associates

The output is shown below:
If volume > 100,000 and Price < $50,000 then buy more. However, if volume ≤50,000, then stop trading. The earnings at volume=100000 is ¼ of the total sales. HTML Tutorial® is a registered trademark.

The above article is © Dr.Liew & Associates

[Lesson 11]<<[Contents]>>[Lesson 13]

Share on FacebookShare on Google+Tweet about this on TwitterShare on LinkedInShare on RedditEmail this to someone