HTML Reference ยท Tables
The <thead> element
Reference for the HTML <thead> element: grouping a table's column-heading rows, sticky headers, repeated headers when printing, and technical details.
The <thead> element groups the row or rows at the top of a <table> that hold the column headings. It separates the labels from the data in <tbody>, which makes styling easier and lets browsers repeat the headings at the top of each printed page.
A table can have only one <thead>, and it comes after any <caption> and <colgroup> elements.
<thead> <tr> <th scope="col">Name</th> <th scope="col">Score</th> </tr> </thead>
Try it
Scroll the box: the heading cells stay at the top because they use position: sticky. Sticky positioning goes on the <th> cells, which works more reliably across browsers than putting it on <thead> itself.
Attributes
This element has no attributes of its own. It accepts the global attributes. The obsolete align, valign, char, charoff and bgcolor attributes should be replaced with CSS.
Usage notes
- Headings belong in
<th>. Putting a row in<thead>does not turn its cells into headers. Use<th>for the heading cells, ideally withscope="col". - Two-level headings. A
<thead>can contain several rows, for example a row of group labels (usingcolspan) above a row of individual column labels. - Printing. When a long table spans several printed pages, browsers repeat the
<thead>rows at the top of each page. - Scripting.
table.tHeadreturns the element,table.createTHead()returns the existing one or creates it, andtable.deleteTHead()removes it.
Technical summary
| Content categories | None |
| Permitted content | Zero or more <tr> and script-supporting elements |
| Tag omission | The start tag is required. The end tag can be omitted if the element is immediately followed by a <tbody> or <tfoot> |
| Permitted parents | A <table>, after any <caption> and <colgroup> elements and before any <tbody>, <tfoot> and <tr> elements, and only if the table has no other <thead> |
| Implicit ARIA role | rowgroup |
| DOM interface | HTMLTableSectionElement |
| Default display | table-header-group |
Browser support
Supported in every browser.
Related
<th>โ header cells<tbody>โ the body rows<tfoot>โ the footer rows- Lesson: Table Headers, Sections and Captions
- Lesson: Styling Tables with CSS