Sunday, 15 March 2009

HTML Special Characters

This document used to live on one of my websites however it doesn't really fit in there any more. I still need it though, so I've moved it here.

For the benefit of those who don't know, HTML special character codes are codes that you can use when writing HTML content and the exist for a number of reasons:
  1. Some characters don't appear on the keyboard. Special character codes provide a means of entering them.

  2. Some characters, the greater-than character for example, have a special meaning in HTML. If you want a browser to display those character rather than trying to interpret them as the part of an HTML tag, you need to use the special character code.

  3. Some characters are language and/or character set dependent (currency symbols being a good example). You need a way to force the viewers browser to display the correct character. Special character codes provide a way of doing this.

The list below is far from complete. There are many more codes to define all kinds of symbols and foreign characters with accents, umlauts and the like. The following list however shows the codes that I use the most frequently.

&lt;<less-than sign
&gt;>greater-than sign
&nbsp;nonbreaking space
&pound;£pound sterling
&trade;trademark sign
&reg;®registered trademark
&deg;°degree sign
&plusmn;±plus or minus
&sup2;²superscript two
&sup3;³superscript three
&times;×multiplication sign
&divide;÷division sign

No comments: