Search This Blog

Wednesday, 1 January 2014

1.24 HTML Entities

Reserved characters in HTML must be replaced with character 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:
&entity_name;
OR
&#entity_number;
To display a less than sign we must write: &lt; or &#60;

Tip: The advantage of using an entity name, instead of a number, is that the name is easier to remember. However, the disadvantage is that browsers may not support all entity names (the support for entity numbers is very good).

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.

Reserved Characters in HTML

Some characters are reserved in HTML and XHTML. For example, you cannot use the greater than or less than signs within your text because the browser could mistake them for markup.

HTML and XHTML processors must support the five special characters listed in the table below:
CharacterEntity NumberEntity NameDescription
"&#34;&quot;quotation mark
'&#39;&apos;apostrophe 
&&#38;&amp;ampersand
<&#60;&lt;less-than
>&#62;&gt;greater-than
Note: Entity names are case sensitive!

ISO 8859-1 Symbols

CharacterEntity NumberEntity NameDescription
 &#160;&nbsp;non-breaking space
¡&#161;&iexcl;inverted exclamation mark
¢&#162;&cent;cent
£&#163;&pound;pound
¤&#164;&curren;currency
¥&#165;&yen;yen
¦&#166;&brvbar;broken vertical bar
§&#167;&sect;section
¨&#168;&uml;spacing diaeresis
©&#169;&copy;copyright
ª&#170;&ordf;feminine ordinal indicator
«&#171;&laquo;angle quotation mark (left)
¬&#172;&not;negation
�­&#173;&shy;soft hyphen
®&#174;&reg;registered trademark
¯&#175;&macr;spacing macron
°&#176;&deg;degree
±&#177;&plusmn;plus-or-minus
²&#178;&sup2;superscript 2
³&#179;&sup3;superscript 3
´&#180;&acute;spacing acute
µ&#181;&micro;micro
&#182;&para;paragraph
·&#183;&middot;middle dot
¸&#184;&cedil;spacing cedilla
¹&#185;&sup1;superscript 1
º&#186;&ordm;masculine ordinal indicator
»&#187;&raquo;angle quotation mark (right)
¼&#188;&frac14;fraction 1/4
½&#189;&frac12;fraction 1/2
¾&#190;&frac34;fraction 3/4
¿&#191;&iquest;inverted question mark
×&#215;&times;multiplication
÷&#247;&divide;division

ISO 8859-1 Characters

CharacterEntity NumberEntity NameDescription
À&#192;&Agrave;capital a, grave accent
Á&#193;&Aacute;capital a, acute accent
Â&#194;&Acirc;capital a, circumflex accent
Ã&#195;&Atilde;capital a, tilde
Ä&#196;&Auml;capital a, umlaut mark
Å&#197;&Aring;capital a, ring
Æ&#198;&AElig;capital ae
Ç&#199;&Ccedil;capital c, cedilla
È&#200;&Egrave;capital e, grave accent
É&#201;&Eacute;capital e, acute accent
Ê&#202;&Ecirc;capital e, circumflex accent
Ë&#203;&Euml;capital e, umlaut mark
Ì&#204;&Igrave;capital i, grave accent
Í&#205;&Iacute;capital i, acute accent
Î&#206;&Icirc;capital i, circumflex accent
Ï&#207;&Iuml;capital i, umlaut mark
Ð&#208;&ETH;capital eth, Icelandic
Ñ&#209;&Ntilde;capital n, tilde
Ò&#210;&Ograve;capital o, grave accent
Ó&#211;&Oacute;capital o, acute accent
Ô&#212;&Ocirc;capital o, circumflex accent
Õ&#213;&Otilde;capital o, tilde
Ö&#214;&Ouml;capital o, umlaut mark
Ø&#216;&Oslash;capital o, slash
Ù&#217;&Ugrave;capital u, grave accent
Ú&#218;&Uacute;capital u, acute accent
Û&#219;&Ucirc;capital u, circumflex accent
Ü&#220;&Uuml;capital u, umlaut mark
Ý&#221;&Yacute;capital y, acute accent
Þ&#222;&THORN;capital THORN, Icelandic
ß&#223;&szlig;small sharp s, German
à&#224;&agrave;small a, grave accent
á&#225;&aacute;small a, acute accent
â&#226;&acirc;small a, circumflex accent
ã&#227;&atilde;small a, tilde
ä&#228;&auml;small a, umlaut mark
å&#229;&aring;small a, ring
æ&#230;&aelig;small ae
ç&#231;&ccedil;small c, cedilla
è&#232;&egrave;small e, grave accent
é&#233;&eacute;small e, acute accent
ê&#234;&ecirc;small e, circumflex accent
ë&#235;&euml;small e, umlaut mark
ì&#236;&igrave;small i, grave accent
í&#237;&iacute;small i, acute accent
î&#238;&icirc;small i, circumflex accent
ï&#239;&iuml;small i, umlaut mark
ð&#240;&eth;small eth, Icelandic
ñ&#241;&ntilde;small n, tilde
ò&#242;&ograve;small o, grave accent
ó&#243;&oacute;small o, acute accent
ô&#244;&ocirc;small o, circumflex accent
õ&#245;&otilde;small o, tilde
ö&#246;&ouml;small o, umlaut mark
ø&#248;&oslash;small o, slash
ù&#249;&ugrave;small u, grave accent
ú&#250;&uacute;small u, acute accent
û&#251;&ucirc;small u, circumflex accent
ü&#252;&uuml;small u, umlaut mark
ý&#253;&yacute;small y, acute accent
þ&#254;&thorn;small thorn, Icelandic
ÿ&#255;&yuml;small y, umlaut mark

No comments:

Post a Comment