Advanced Table Tags
While it is possible to build a simple table quickly, complex tables with varying border styles, running headers and footers, and column-based layout were not easily constructed from the old HTML 3.2 table model. Microsoft rectified this inadequacy somewhat by adding a number of table-layout controls to Internet Explorer Version 3.0. These very useful extensions found their way into the HTML 4 standard and subsequently into XHTML. They provide row-based grouping and running headers and footers, along with column-based layout features.
There is good news and bad news about these table features, of course. They provide a nice way to make your tables more attractive and presentable, but they currently work only within Internet Explorer and Netscape 6. If you choose to use them, make sure your tables stand up with the older browsers, too.
Defining Table Sections
Within
tables, all rows are created equal. In real tables, some rows are
more equal than others. And most tables have header and footer rows
that repeat from page to page. In large tables, adjacent rows are
grouped and delineated with different rule lines to make the tables
easier to read and understand. HTML 4 and XHTML support all of these
features with the <thead>
,
<tfoot>
, and
<tbody>
tags.
The <thead> Tag
Use the <thead>
tag to
define a set of table header rows. The
<thead>
tag may appear only once per table
and is placed at the beginning, just after the
<table>
tag. Within the
<thead>
tag, you may ...
Get HTML & XHTML: The Definitive Guide, 5th Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.