<thead>
A group of rows with the table’s column headers.
- Display
- table-header-group
- Closing tag
- Required
- Permitted content
<tr>elements
Example
#<style>
table { border-collapse: collapse; }
th, td { border: 1px solid #8886; padding: 4px 10px; text-align: left; }
thead { background: #8b5cf633; }
</style>
<table>
<thead>
<tr>
<th scope="col">Lesson</th>
<th scope="col">Time</th>
</tr>
</thead>
<tbody>
<tr><td>Tags and attributes</td><td>12 min</td></tr>
<tr><td>Lists</td><td>9 min</td></tr>
</tbody>
</table>Definition and usage
#The <thead> element wraps a row (or several rows) with column headers. In a table it comes after <caption> and <colgroup> and before <tbody>. Inside it you put <tr> elements, and in them usually <th> cells.
Splitting a table into <thead>, <tbody>, and <tfoot> organizes it and makes styling easier. For example, the rule thead th { position: sticky; top: 0; } sticks the headers to the top edge of a scrolling container.
When printing a long table, browsers may repeat <thead> at the top of every page, so the reader doesn’t lose track of the column names.
Syntax
#<thead>
<tr>
<th>…</th>
</tr>
</thead>Attributes
#This element has no attributes of its own. It supports the global attributes, such as class, id and hidden.
Default CSS
#Most browsers display this element with these default styles:
thead {
display: table-header-group;
vertical-align: middle;
}Browser support
#Widely available
Works in all modern browsers, phones included. You can use it without worry.
- Chrome
- Edge
- Firefox
- Safari
Good practices
#- A table can have only one
<thead>. - Simply placing a row in
<thead>isn’t enough. Keep writing the header cells as<th>.
Related entries
#Practise it in lessons
#Spotted a mistake or missing an example? Write to us.