Tutorial 17: Shady Characters - HTML with Style | 6
Character entity references allow you to use a simple, memorable name instead of a number to refer to a character. The upside of this approach is twofold: First of all, as humans, we are more likely to remember a name like "quot" instead of the number 34 (which is the number to use for a quotation mark in a numerical character reference). Secondly, browsers will tend to handle character entity references they know about more reliably than numerical character references, as character entity references can refer to a character without making assumptions about the character set or encoding. A user agent should understand the entity reference "quot" as the character with number 34, but even if it doesn't, it's still a quotation mark.
The downside of character entity references is again twofold: First, some of the names of character entity references are not easy to remember or even decipher - who can figure out that "raquo" stands for "right-pointing double angle quotation mark" (or even know what that is). Secondly, not all user agents understand all character entity references. HTML 4.0 may define a whole slew of these, but Netscape will probably crease its eyebrows at more than half of them.
<P>The pub we went to was named the «Horse & Carriage». They served fine draught ale for just £1.20.</P>
Since character entity references refer to characters in the document character set, it is generally better to use the actual character encoded in the document instead of using them, for the same reasons that numerical character references should be avoided. However, there is one important exception: Look at the example above again. What if I had used the ampersand character directly? A user agent reading the document might be mistaken into believing that it denoted a character reference. And what if I literally wanted to include the letters (&) in my document? More importantly, what if I wanted to use the less-than or greater-than sign in my document, without implying that a tag begins or ends at that point? The answer is to use the character entity references <, > and & whenever you want to insert a greater-than, less-than, or ampersand character in your document without implying an entity or character reference, or a tag. The following example illustrates this:
<P>Elementary mathematics states that 3 < 5 > 1.</P> <P>To insert an ampersand in an HTML document, you should use the syntax &amp;</P>
Elementary mathematics states that 3 < 5 > 1.
To insert an ampersand in an HTML document, you should use the syntax &
If I did not use named character entity references in the above example, a user agent would be mystified by the start-tag for the mysterious "5" element, and render the ampersand character entity reference as an ampersand, making the tutorial writer's job quite impossible. For this reason, you must always use character entity references when using the ampersand, greater-than and less-than characters in your documents.