HTML Table Sections: thead, tbody and tfoot
Group the header and body
thead holds heading rows and tbody holds the main records. Each group contains tr elements, not individual cells. Header semantics still belong to th.
<table> <caption>Orders</caption> <thead> <tr> <th scope="col">Day</th> <th scope="col">Count</th> </tr> </thead> <tbody> <tr> <td>Monday</td> <td>12</td> </tr> </tbody></table>The heading row and the data row belong to separate groups.
Add a summary footer
Use tfoot for summary rows, after the body groups in modern authoring order. It does not calculate anything automatically; supply the total yourself or calculate it with application code later.
<table> <caption>Tickets</caption> <thead> <tr> <th scope="col">Day</th> <th scope="col">Count</th> </tr> </thead> <tbody> <tr> <th scope="row">Monday</th> <td>12</td> </tr> <tr> <th scope="row">Tuesday</th> <td>9</td> </tr> </tbody> <tfoot> <tr> <th scope="row">Total</th> <td>21</td> </tr> </tfoot></table>The footer contains the supplied sum, 21.
Understand body groups
A table may contain multiple tbody groups. This example separates morning and afternoon records. If you omit tbody and write rows directly inside table in HTML source, the HTML parser normally creates an implicit tbody in the DOM. Explicit groups make the structure easier to read.
<table> <caption>Shift attendance</caption> <thead> <tr> <th scope="col">Shift</th> <th scope="col">People</th> </tr> </thead> <tbody> <tr> <th scope="row">Morning</th> <td>8</td> </tr> </tbody> <tbody> <tr> <th scope="row">Afternoon</th> <td>6</td> </tr> </tbody></table>Two body groups are present; their boundaries may not be visually obvious.
Common mistakes and practice
Do not place td directly inside tbody or expect thead to turn td into th. Inspect a table without explicit tbody in your browser’s Elements panel to see the inserted group.
Check Your Understanding
Solidify your learning with the interactive assessment directly below this lesson.
Concept Quiz & Questions
HTML Table Sections: thead, tbody and tfoot — Knowledge Check
Apply table structure and accessibility concepts from this lesson.
Which element groups the main records?
What does tfoot calculate automatically?
What can the HTML parser insert when source rows are direct children of table?
Which element groups column-heading rows?
Can a table contain multiple tbody groups?