Tables can be divided into three major blocks of a header, body, and footer. The header and footer are similar to headers and footers in a document of a word-processor like MS-Word that remain the same for every page, while the body is the main content of the table.
Similarly HTML has three tags for the header, body, and footer of a table
- <thead> – to create a separate table header.
- <tbody> – to indicate the main body of the table.
- <tfoot> – to create a separate table footer.
A table may have many <tbody> tags to specify different pages or groups of data. But <thead> and <tfoot> tags should appear before the <tbody> tag.
HTML code <table border=”1″ > <thead> <tr> <td colspan=”2″>Header</td> </tr> </thead> <tfoot> <tr> <td colspan=”2″>Footer</td> </tr> </tfoot> <tbody> <tr> <td>Cell 1</td> <td>Cell 2</td> </tr> </tbody> <tbody> <tr> <td>Cell 1</td> <td>Cell 2</td> </tr> </tbody> </table> | Browser output |