Tutorials Bugs Masterclass Free stuff Test pages Proposals

Basic concepts

Advanced concepts

RichInStyle.com HTML 4 guide - Essential concepts


Character references


Character references

There are times when the character you need to include in your web page can't be directly included. For example, you might want to include a <, which would otherwise be difficult because browsers would interpret it as opening a tag, and therefore destroy the rest of the page.

Fortunately HTML provides a means of doing this, known as character references (or sometimes as escapes). To do this you use the & sign followed by up to 6 letters specifying the character that you want and then a semicolon. The code for <, for example, is &lt; (lt for less than).

Other useful characters include the non-breaking space, referred to by &nbsp;. This specifies that there must be a space there. For example,        a lot of space was caused to the left of this by the use of some non-breaking spaces.

The other main characters are &amp;, which specifies that you want an ampersand and &gt;, which specifies that you want a greater than sign (this shouldn't be necessary, but Word 95 and 97 will ignore plain >, but won't ignore &gt;).

Beyond this there are other characters that are useful because they don't appear on computer keyboards and therefore cannot easily be entered. For example:

Character reference Meaning Rendering
&iexcl; Inverted exclamation ¡
&iquest; Inverted question mark ¿
&eacute; Lowercase e with acute accent é
&Eacute; Uppercase e with acute accent É
&agrave; Lowercase a with grave accent à
&uuml; Lowercase u with umlaut ü
&ocirc; Lowercase o with circumflex ô
&cent; Cent ¢
&pound; English pound sign £
&yen; Yen ¥
&copy; Copyright ©
&reg; Registered trademark ®
&ccedil; Lowercase c with cedilla ç
&times; Times sign ×
&divide; Divide sign ÷
&deg; Degrees °
&plusmn; Plusminus ±

Note that the list above only lists a subset of the available entities. However, the form is indicated, so although the O with circumflex is not listed, it is obvious that the correct reference is &Ocirc;


Very often you want to include some text in a file, perhaps as a reminder to yourself, but you don't want it to appear on screen when someone looks at the page in their web browser. In order to cater for this, you can use the comment tags, <!-- and -->. These tags delimit the comment. For example:

This won't be rendered
But this will.

Note that they differ slightly from normal tags insofar as they do not have a / on closing.

The one point of note is that you should not include '--' inside comments except at the comment's end. For example, <!-- This is -- a comment --> is bad.

That's the end of this part of the HTML guide. The next section considers images, so I suggest you click here to continue.