basics of website design banner photo

HTML

HTML 5

CSS 2.1

CSS 3

Reference

HTML Entities

When writing HTML or XHTML there are certain special characters which are reserved for use within the code, for example the less-than '<' and greater-than '>' signs are used to indicate the opening and closing of tags. In order to avoid possible confusion between markup and text these special characters are replaced in the code for the page with something known as an entity reference.

Whenever you need to use the character in your coding you replace it with the entity reference which is then interpreted by the browser and displayed as the designated character. Characters can be represented by an entity name or an entity number, support for numbers is universal but support for names isn't so we recommend using numbers.

Here is a table showing the characters which have significance when writing (X)HTML along with their entity name and entity number:

Character Entity Name Entity Number Description
" &quot; &#34; quotation mark
& &amp; &#38; ampersand
' &apos; &#39; apostrophe
< &lt; &#60; less-than
> &gt; &#62; greater than

Code example

As an example to show an opening paragraph tag on the screen you would have to code it as: &#60;p&#62; giving you: <p>.

Other Entity References

Every ascii keyboard character and many other symbols have an entity reference number which can be used in their place when you are coding. You may ask why have entity numbers when you can use the keyboard but not everyone uses the same keyboard and the entity references are universal and don't rely on you having the correct keyboard. They give you a means to add symbols and letters from different languages to your web pages such as German, French and Spanish words with the correct accents over the letters.

This table lists a few of the entities you may find useful when you are designing:

Character Entity Name Entity Number Description
© &copy; &#169; copyright
® &reg; &#174; registered trademark
&trade; &#8482; trademark sign
¼ &frac14; &#188; fraction ¼
½ &frac12; &#188; fraction ½
¾ &frac34; &#190; fraction ¾
  &nbsp; &#160; space
&euro; &#8364; euro sign
° &deg; &#176; degree
~ &tilde; &#126; tilde
² &sup2; &#178; superscript 2
³ &sup3; &#179; superscript 3

Encoding spaces

One thing to remember is that however many continuous spaces(using the space bar) you write into a page browsers will only display one space, ignoring all the others. To overcome this you must use the entity reference for space '&#160;' for any additional spaces after the first.