Site Sponsors

Archive for the ‘Special Characters’ Category

HTML and XHTML entities and special characters

Saturday, February 16th, 2008

Within XHTML there are some characters which need replacing with valid XHTML entities or special charaters otherwise they will error when validiting your code in the W3C. This is also known as HTML Encoding.

There are three parts to building the entity.

  1. & (ampersand) - the entity always starts of with this character.
  2. Number or Word - this is the part of the entity which changes. This can either be a word or a number eg. amp or #38
  3. ; (semi-colon) - the entity always ends with this character.

Note: all entities are case sensitive.

Character Numeric character reference Character entity reference Description
" " Double quote
& & & Ampersand
< &#60; &lt; Less than
> &#62; &gt; Greater than
  &#160; &nbsp; Non-breaking space
¢ &#162; &cent; Cent sign
£ &#163; &pound; Pound sign