HTML and CSS Reference
In-Depth Information
<td>27</td>
</tr>
<tr>
<th scope="row">Smoke Pellets</th>
<td>623</td>
</tr>
</tbody>
</table>
Basically, the rule to remember here is that if you're using table row groupings—
thead
,
tbody
, and
tfoot
—try to use as many of them as makes sense for your table. We recommend using table row
groupings for all but the simplest tables; the organizational and accessibility benefits are worth it!
The
tbody
element, like the
thead
and
tfoot
elements, must appear as a direct child of its parent
table
element. Additionally,
tbody
elements must be included after any
caption
,
colgroup
, and
thead
elements, should they be present.
The rules governing start tag omission for the
tbody
element are slightly more elaborate than most tag
omission rules. The
tbody
element's start tag may be omitted if its first child is a
tr
element and if the
immediately preceding
tbody
,
thead
, or
tfoot
element does not have its end tag omitted. Most browsers
will insert an implied
tbody
element into the DOM. Our best-practice recommendation to you is this: if
you're going to use the
tbody
element, always include the start tag, particularly if you're using the other
row grouping elements.
Less confusingly, the
tbody
element's end tag may be omitted if it is immediately followed by a
tbody
or
tfoot
element, or if there is no more content in the table. But including end tags is always a safe bet.
Required Attributes
There are no required elements for the
tbody
element.
Optional Attributes
Beyond the global attributes, there are no additional optional attributes for the
tbody
element.
tfoot
The optional
tfoot
element, known as a table footer row group, represents a row or rows whose content
consists of the column summaries for its parent
table
element. A large table containing sales data for,
say, superhero supplies, may include a
tfoot
row grouping containing a row of cells with sums denoting
inventory, similar to that shown in Listing 7-15.