HTML and CSS Reference
In-Depth Information
16.3. HTML Versus XHTML
The majority of HTML is completely compatible with XHTML, and this
book is devoted to that majority. In this chapter, however, we talk about
the minority: where the HTML 4.01 standard and the XHTML DTD differs.
If you truly desire to create documents that are both HTML and XHTML
compliant, you must heed the various warnings and caveats we outline
in the following sections.
The biggest differencethat's Difference with a capital D and that spells
difficultis that writing XHTML documents requires much more discipline
and attention to detail than even the most fastidious HTML author ever
dreamed necessary. In W3C parlance, that means your documents must
be impeccably well formed. Throughout the history of HTMLand in this
bookauthors have been encouraged to create well-formed documents,
but you have to break rank with the HTML standards for your documents
to be considered well formed by XML standards.
Nonetheless, your efforts to master XHTML will be rewarded with docu-
ments that are well formed and a sense of satisfaction from playing by
the new rules. You will truly benefit in the future, too: through XML, your
documents will be able to appear in places you never dreamed would ex-
ist (mostly good places, we hope).
16.3.1. Correctly Nested Elements
One requirement of a well-formed XHTML document is that its elements
are nested correctly. This isn't any different from the HTML standards:
simply close the markup elements in the order in which you opened
them. If one element is within another, the end tag of the inner element
must appear before the end tag of the outer element.
Hence, in the following well-formed XHTML segment, we end the italics
tag before we end the bold one, because we started italicizing after we
started bolding the content:
<b>Close the italics tag <i>first</i></b>.
Search WWH ::

Custom Search