tbody 元素應該與 thead 和 tfoot 元素結合起來使用,共同實現表格的分組顯示(Structured Table)。以下分三部分說明。
表格可依行分為三個區域:
<thead>...</thead>:表格的題頭(Header)<tbody>...</tbody>:表格的正文(Body)<tfoot>...</tfoot>:表格的腳註(Footer)示例:
<table border> <thead> <tr><th>Food</th><th>Drink</th><th>Sweet</th></tr> </thead> <tbody> <tr><td>A</td><td>B</td><td>C</td></tr> <tr><td>D</td><td>E</td><td>F</td></tr> </tbody> </table>
使用 <colgroup align="#"> 可以對列進行分組,align 可設為 left、right 或 center。
示例:
<table border width=160> <colgroup align=left> <colgroup align=center> <colgroup align=right> <thead> <tr><th>Food</th><th>Drink</th><th>Sweet</th></tr> </thead> <tbody> <tr><td>A</td><td>B</td><td>C</td></tr> </tbody> </table>
使用 <col span="#"> 可以一次為多列套用相同屬性,其中 span 代表從左數起具有指定屬性的列數,align 則設定對齊方式。
示例:
<table border width=160> <colgroup> <col align=center span=2> <colgroup align=right> <thead> <tr><th>Food</th><th>Drink</th><th>Sweet</th></tr> </thead> <tbody> <tr><td>A</td><td>B</td><td>C</td></tr> </tbody> </table>