Thursday, April 18, 2013

HTML Entities

HTML Entities
Some characters are reserved in HTML.
It is not possible to use the less than (<) or greater than (>) signs in your text, because the browser will mix them with tags.

To actually display reserved characters, we must use character entities in the HTML source code.

A character entity looks like this:
To display a less than sign we must write: &lt; or &#60;

Non-breaking Space 
A common character entity used in HTML is the non-breaking space (&nbsp;).
Browsers will always truncate spaces in HTML pages. If you write 10 spaces in your text, the browser will remove 9 of them, before displaying the page. To add spaces to your text, you can use the &nbsp; character entity. 

HTML Entities Example 
Experiment with HTML character entities: Try it yourself

HTML Useful Character Entities
 Note: Entity names are case sensitive!

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;
§ section &sect; &#167;
© copyright &copy; &#169;
® registered trademark &reg; &#174;
trademark &trade; &#8482;

No comments:

Post a Comment

Kebahagiaan sejati bukanlah pada saat kita berhasil meraih apa yg kita perjuangkan, melainkan bagaimana kesuksesan kita itu memberi arti atau membahagiakan orang lain.