The , , and tags aren??™t optional in XHTML; they must be
included explicitly in the markup. It??™s permissible, even in XHTML, to omit the
and tags in simple tables, not because the tags are optional??”there??™s
no such thing as an optional tag in XML??”but because XHTML allows two content
models for the table element type.
Whereas HTML regards the tbody element tags as optional (thereby making them
implicit), the XHTML specification states that a table must contain either one or
more tbody elements, or one or more tr elements (after any optional caption, col,
colgroup, thead, and tfoot elements).
The important difference is that, in an XHTML document, a table element that
lacks and tags won??™t contain a tbody element node in the DOM
tree. In HTML, the tbody element will be present in the DOM tree whether or not
the tags are present.
This variation can affect our use of CSS in specific cases. Consider the following
CSS rules, which set a medium font weight for header cells in the table body
Differences Between HTML
and XHTML
The Ultimate CSS Reference 414
(presumably row headers), and a bold font for other header cells (for example, those
in a thead element):
th {
font-weight: bold;
}
tbody th {
font-weight: normal;
}
Now, let??™s look at two different ways to write the markup for a simple table: