Using thead, tbody, and tfoot

Question: Can you show me a sample of how I should make use of the thead, tfoot, and tbody tags? Not knowing how many pages the table will stretch will it affect the way the headers and footers work? Which are the browsers that support thead, tbody, and tfoot?

Answer: These commands are recognised by Internet Explorer 3+, Netscape 6+, and Opera 4+ although some of the sub-parameters allowed by the HTML4 specification were not supported until later versions of the browsers and unfortunately from what I have been able to find out none of the browser versions currently available will actually print the thead and tfoot information on every page when the table is split over multiple pages. This makes the use of these tags rather pointless at present but support may be introduced in future browser versions and so you may want to code your tables this way so as to be ready.

Here is a table that uses the thead, tbody, and tfoot commands.

Header Text
Footer text
line one data
line two data
line three data
line four data
line five data
line six data
line seven data
line eight data

The code for the above table is as follows:

 <table width="150" class="centre" cellspacing="0" cellpadding="5" border="1">
<thead><tr><th>Header Text</th></tr></thead>
<tfoot><tr><th>Footer text</th></tr></tfoot>
<tbody><tr><td>line one data</td></tr>
<tr><td>line two data</td></tr>
<tr><td>line three data</td></tr>
<tr><td>line four data</td></tr>
<tr><td>line five data</td></tr>
<tr><td>line six data</td></tr>
<tr><td>line seven data</td></tr>
<tr><td>line eight data</td></tr></tbody>

The tfoot data immediately follows the thead data. This is to ensure that the tfoot information is available to be used when the table information is to be split. Where your visitors use browsers that do not recognise these commands this will have the unfortunate result of displaying the footer at the top of the table rather than at the bottom.


This article written by Stephen Chapman, Felgall Pty Ltd.

go to top

FaceBook Follow
Twitter Follow