The elements thead, tbody and tfoot are used to create logically separate row groups. See the (relevant HTML4.01 specs). Their attributes are the same as the tr attributes but they provide a more convenient way to apply a set of attributes to a group of rows at a time. Furthermore, the table lines can be specified to respect the groups.
The thead and tfoot groups are meant to function so that whatever rows are put into them go to the top and bottom of the table, respectively. However, I wouldn't count on this actually working. In fact, you really only need the tbody element since it can be used whenver you want to create a row group.
Let's revisit our working example from the last set of notes with border and cellpadding specified:<table summary="" border="1" cellpadding="10px"> <tr> <th colspan="3">Source: RTFM bulletin</th> </tr> <tr> <th>1990</th> <th>2000</th> <th>type</th> </tr> <tr> <td>5.31</td> <td>4.2</td> <td>percent increase</td> </tr> <tr> <td>$30,333</td> <td>$46,576</td> <td>hardware<br />and<br />software</td> </tr> </table>which gives us this appearance:
| Source: RTFM bulletin | ||
|---|---|---|
| 1990 | 2000 | type |
| 5.31 | 4.2 | percent increase |
| $30,333 | $46,576 | hardware and software |
<table summary="" border="1" cellpadding="10px"> <tr> <th colspan="3">Source: RTFM bulletin</th> </tr> <tbody align="right"> <tr> <th>1990</th> <th>2000</th> <th>type</th> </tr> <tr> <td>5.31</td> <td>4.2</td> <td>percent increase</td> </tr> <tr> <td>$30,333</td> <td>$46,576</td> <td>hardware<br />and<br />software</td> </tr> </tbody> </table>and here is its appearance:
| Source: RTFM bulletin | ||
|---|---|---|
| 1990 | 2000 | type |
| 5.31 | 4.2 | percent increase |
| $30,333 | $46,576 | hardware and software |
<table summary="" border="1" frame="box" rules="groups" cellpadding="10px"> <tr> <th colspan="3">Source: RTFM bulletin</th> </tr> <tr> <th>1990</th> <th>2000</th> <th>type</th> </tr> <tbody> <tr> <td>5.31</td> <td>4.2</td> <td>percent increase</td> </tr> <tr> <td>$30,333</td> <td>$46,576</td> <td>hardware<br />and<br />software</td> </tr> </tbody> </table>and here is its appearance:
| Source: RTFM bulletin | ||
|---|---|---|
| 1990 | 2000 | type |
| 5.31 | 4.2 | percent increase |
| $30,333 | $46,576 | hardware and software |
Unfortunately, the col and colgroup elements may not work uniformly across all browsers and using the width in td and th elements, although deprecated, often creates more portable HTML code.
Here is an example using the col element:<table summary="" border="1" cellpadding="10px"> <col span="2" width="200" ></col> <tr> <th colspan="3">Source: RTFM bulletin</th> </tr> <tr> <th>1990</th> <th>2000</th> <th>type</th> </tr> <tr> <td>5.31</td> <td>4.2</td> <td>percent increase</td> </tr> <tr> <td>$30,333</td> <td>$46,576</td> <td>hardware<br />and<br />software</td> </tr> </table>and here is its appearance:
| Source: RTFM bulletin | ||
|---|---|---|
| 1990 | 2000 | type |
| 5.31 | 4.2 | percent increase |
| $30,333 | $46,576 | hardware and software |
The colgroup elements constructs a column group much as the tbody elements construct row groups.
<table summary="" border="1" frame="box" rules="groups" cellpadding="10px"> <colgroup span="2"></colgroup> <tr> <th colspan="3">Source: RTFM bulletin</th> </tr> <tr> <th>1990</th> <th>2000</th> <th>type</th> </tr> <tr> <td>5.31</td> <td>4.2</td> <td>percent increase</td> </tr> <tr> <td>$30,333</td> <td>$46,576</td> <td>hardware<br />and<br />software</td> </tr> </table>has this appearance
| Source: RTFM bulletin | ||
|---|---|---|
| 1990 | 2000 | type |
| 5.31 | 4.2 | percent increase |
| $30,333 | $46,576 | hardware and software |
<table summary="" border="1" frame="box" rules="groups" cellpadding="10px"> <colgroup span="2"></colgroup> <tbody> <tr> <th colspan="3">Source: RTFM bulletin</th> </tr> </tbody> <tr> <th>1990</th> <th>2000</th> <th>type</th> </tr> <tbody valign="top"> <tr> <td>5.31</td> <td>4.2</td> <td>percent increase</td> </tr> <tr> <td>$30,333</td> <td>$46,576</td> <td>hardware<br />and<br />software</td> </tr> </tbody> </table>which looks like this:
| Source: RTFM bulletin | ||
|---|---|---|
| 1990 | 2000 | type |
| 5.31 | 4.2 | percent increase |
| $30,333 | $46,576 | hardware and software |