HTML <thead> / <tbody> tags
- closing tag
- required (both)
- void element
- no
- lives inside
- <table>
- typically holds
- <tr> rows
Where it goes
Directly inside <table>: <thead> with the header row, then <tbody> with everything else.
Example
<table>
<thead>
<tr><th scope="col">Name</th><th scope="col">Age</th></tr>
</thead>
<tbody>
<tr><td>Ann</td><td>30</td></tr>
</tbody>
</table>Open this example in the editor →
Common mistakes
- Putting rows directly in <table> next to a <tbody>. The browser wraps the loose rows in a second, invisible <tbody>.
- Using <thead> for the table's title. The header is for column names. A title goes in <caption>, right after the opening <table> tag.
- Fighting CSS to make the header row look different. <thead> gives you a selector for exactly that.