HTML <thead> Tag

Beginner
⏱️ 5 min read
📚 Updated: Jun 2026
🎯 3 Examples
Tables

What You’ll Learn

The <thead> tag groups header rows in a table. This guide covers syntax, th cells, thead/tbody/tfoot structure, multi-level headers, CSS styling, accessibility, and best practices for beginners.

01

Header Group

Row group element.

02

th Cells

Column labels.

03

tbody Pair

Headers vs data.

04

Core Syntax

Inside table element.

05

Multi-Level

colspan headers.

06

Best Practices

Semantic structure.

What Is the <thead> Tag?

The <thead> tag is an HTML element used inside <table> to define the header section of a table. It groups one or more tr rows that contain th header cells, separating column labels from data in tbody.

Valid HTML5 — Table Row Group

thead wraps header rows with th cells. Pair it with tbody for data and tfoot for summaries when needed.

If you omit thead, browsers may still render header rows, but writing thead explicitly improves semantics, styling, and accessibility.

📝 Syntax

Place thead inside table with tr rows containing th cells:

syntax.html
<table>
  <thead>
    <tr>
      <th>Header 1</th>
      <th>Header 2</th>
    </tr>
  </thead>
  <tbody>
    <!-- Data rows with td cells -->
  </tbody>
</table>

Full Table Example

thead-tbody.html
<table>
  <thead>
    <tr>
      <th scope="col">Name</th>
      <th scope="col">Email</th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <td>John</td>
      <td>john@example.com</td>
    </tr>
  </tbody>
</table>

Syntax Rules

  • thead must be a direct child of table (along with caption, colgroup, tbody, and tfoot).
  • Only tr elements go directly inside thead.
  • Place thead before tbody and tfoot in source order.
  • Use th (not td) for header cells inside thead.
  • A table may contain at most one thead element.

⚡ Quick Reference

TopicCode SnippetNotes
Basic thead<thead>...</thead>Header row group
Header cells<th>...</th>Inside tr
With tbodythead + tbodyHeaders + data
Multi-rowMultiple tr in theadGrouped headers
vs ththead = groupth = cell
Browser supportUniversalAll browsers

⚖️ <thead>, <tbody>, and <tfoot>

ElementContainsTypical cells
<thead>Header rowsth column labels
<tbody>Main data rowstd data values
<tfoot>Footer / summary rowsTotals, metadata
Order in HTMLtheadtbodytfootSemantic grouping

⚖️ <thead> vs <th>

ElementRoleAnalogy
<thead>Row group container for headersThe header section of the table
<th>Individual header cellOne column or row label
Relationshipthead contains trthSection wraps cells

🧰 Attributes

The <thead> tag has no tag-specific attributes. Use colspan and rowspan on child th cells for complex headers.

attributes.html
<thead class="table-header">
  <tr>
    <th colspan="2">Merged Header</th>
    <th rowspan="2">Spanned Header</th>
  </tr>
</thead>
class / id Global

Style all header rows in the thead section with one CSS selector.

class="table-header"
colspan on th On th

Merge header cells horizontally across multiple columns.

colspan="2"
rowspan on th On th

Span a header cell vertically across multiple header rows.

rowspan="2"
scope on th A11y

Declare column or column-group labels on th cells inside thead.

scope="col"

Examples Gallery

Basic header sections, merged header cells, and multi-level header layouts with copy-ready code and live previews.

👀 Live Preview

Table with thead column headers and tbody data rows:

First NameLast NameEmail
JohnDoejohn@example.com
JaneSmithjane@example.com

📚 Common Use Cases

Use <thead> to group header rows, label columns with th, and build accessible table structure.

Basic Table Header

The primary purpose of thead is defining the header section of a table:

basic-table-header.html
<table>
  <thead>
    <tr>
      <th>First Name</th>
      <th>Last Name</th>
      <th>Email</th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <td>John</td>
      <td>Doe</td>
      <td>john@example.com</td>
    </tr>
  </tbody>
</table>
Try It Yourself

Merged Header Cells

Use colspan and rowspan on th cells inside thead:

merged-headers.html
<thead>
  <tr>
    <th colspan="2">Merged Header</th>
    <th rowspan="2">Spanned Header</th>
  </tr>
  <tr>
    <th>Header 1</th>
    <th>Header 2</th>
  </tr>
</thead>
Try It Yourself

Multi-Level Headers

Use multiple tr rows in thead with colspan for grouped labels:

spanning-headers.html
<thead>
  <tr>
    <th colspan="2">Personal Information</th>
    <th>Email</th>
    <th>Phone</th>
  </tr>
  <tr>
    <th>First Name</th>
    <th>Last Name</th>
    <th>Email</th>
    <th>Phone</th>
  </tr>
</thead>
Try It Yourself

♿ Accessibility

  • Use thead on data tables — Group column headers so assistive tech recognizes the header section.
  • Use th inside thead — Header cells should be th, not td, for correct semantics.
  • Add scope on th — Use scope="col" or scope="colgroup" for multi-level headers.
  • Pair with tbody — Data rows in tbody are associated with headers in thead.
  • Add a caption — A caption describes the table before users read individual headers.

🧠 How <thead> Works

1

Author groups header rows

tr rows with th cells go inside thead.

Markup
2

Browser separates sections

thead headers and tbody data render as distinct row groups.

Structure
3

CSS styles the header

Classes on thead or th make headers visually distinct.

Design
=

Organized table headers

Column labels are semantically grouped, styled, and accessible to all users.

Browser Support

The <thead> tag is supported in all major browsers, including Internet Explorer.

Baseline · HTML4 / HTML5

Table header section everywhere

All browsers render <thead> as the standard table header row group.

100% Core tag support
Google Chrome Fully supported
Full support
Mozilla Firefox Fully supported
Full support
Apple Safari Fully supported
Full support
Microsoft Edge Fully supported
Full support
Internet Explorer Fully supported · EOL
Full support
Opera Fully supported
Full support
<thead> tag 100% supported

Bottom line: Use <thead> confidently to group table header rows in any browser.

Conclusion

The <thead> tag is essential for well-structured HTML tables. By grouping header rows with th cells separately from body data, you improve clarity, styling control, and accessibility in tabular content.

💡 Best Practices

✅ Do

  • Use thead with th on every data table
  • Place thead before tbody in source order
  • Style thead with CSS for visual header distinction
  • Use colspan and rowspan for multi-level headers

❌ Don’t

  • Put data values in thead using td cells
  • Skip headers on tables that need column context
  • Use obsolete align or valign on thead
  • Use tables (and thead) for page layout

Key Takeaways

Knowledge Unlocked

Six truths every developer should know about <thead>

Bookmark these before you structure your next HTML table.

6
Core concepts
📑 02

th Cells

Column labels.

Content
📐 03

tbody

Data section.

Pairing
⚖️ 04

vs th

Group vs cell.

Comparison
05

Semantic

Clear structure.

A11y
🌐 06

100% Support

All browsers.

Compatibility

❓ Frequently Asked Questions

It groups header rows in a table, typically containing th cells that label each column.
One or more tr rows with th header cells. Data rows belong in tbody with td.
thead is the row group container. th is the individual header cell inside it.
Yes. Use multiple tr rows for multi-level headers with colspan and rowspan on th cells.
Yes. Full support in every major browser including Internet Explorer.

Group your table header rows

Practice <thead> with <th> and <tbody> in the Try It editor.

Try basic header example →

About the author

Mari Selvan M P
Mari Selvan M P 🔗

Developer, cloud engineer, and technical writer

  • Experience 12 years building web and cloud systems
  • Focus Full Stack Development, AWS, and Developer Education

I write practical tutorials so students and working developers can learn by doing—from databases and APIs to deployment on AWS.

6 people found this page helpful