Web browsers are forgiving of sloppy HTML, but XHTML (being an XML
application) requires fastidious attention to every detail. These
requirements were outlined briefly in the XML chapter (Chapter 30, "Introduction to XML"), but we'll go over them in this section
as they relate specifically to XHTML.
31.4.7. Character Entities
XHTML (as a function of XML) is
extremely fussy about special characters such as
<, >,
&, etc. All special characters should be
represented in the XHTML document by their character entities
instead. Common character entities are listed in Table 10-3, and the complete list appears in Appendix F, "Character Entities".
Character entity references should be used in place of characters
such as < and & in
regular text content, as shown in these exmples.
<p> the value of A < B </p>
<p> Laverne & Shirley </p>
Places where it was common to use special characters, such as in the
title of a document or in an attribute value, it is necessary to use
the character entity instead. For instance, the following worked just
fine in HTML:
<img src="puppets.jpg" alt="Crocco & Lynch"/>
But in XHTML, the value must be written like this:
<img src="puppets.jpg" alt="Crocco & Lynch"/>