HTML <thead> Tag

Beginner
6 min read
Updated: Nov 2026
4 examples
Live preview

Definition and Usage

The <thead> element groups the header rows of a <table>. Those rows usually hold column titles made with <th> inside <tr> elements.

Pair it with <tbody> for data and <tfoot> for summaries. A table may have only one <thead>. Place it after any <caption> / <colgroup>, and before tbody, tfoot, and bare rows. On printouts, the head often repeats on each page.

Baseline · Widely available.

Not deprecated. Core thead support has been stable across browsers since about July 2015 (and much earlier in practice).

Deprecated attributes.

Do not use align, bgcolor, char, charoff, or valign on <thead>. Prefer CSS text-align, background-color, and vertical-align.

HTML Syntax

syntax.html
<thead> tr rows</thead>

The start tag is required. The end tag may be omitted when <tbody> or <tfoot> follows immediately, but writing both tags is clearer. Content is zero or more <tr> rows.

Attributes

Modern <thead> has no current element-specific attributes — only global attributes. These older attributes are deprecated (shown for migration):

AttributeDescriptionTry it
alignDeprecated — use CSS text-align insteadTry it
bgcolorDeprecated — use CSS background-color insteadTry it
valignDeprecated — use CSS vertical-align insteadTry it
char / charoffDeprecated — use CSS text-align (and tabular numerals) insteadTry it

Inside the head, use scope on <th>, and colspan / rowspan for multi-row headers.

Global Attributes

The <thead> tag also supports the Global Attributes in HTML.

Live Preview

Switch column titles inside a real <thead>.

A real table with one <thead>. Only one head group is allowed per table.

Table
Team roster
NameRole
AdaDesigner
GraceDeveloper

thead: Name / Role

HTML Examples

Short, copy-ready snippets. Use Try It Yourself for a live editor.

Example 1 — Basic thead

Put column titles in <thead> and data rows in <tbody>.

HTML
<table>
  <thead>
    <tr>
      <th>Student ID</th>
      <th>Name</th>
      <th>Credits</th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <td>101</td>
      <td>Ada</td>
      <td>240</td>
    </tr>
    <tr>
      <td>202</td>
      <td>Grace</td>
      <td>220</td>
    </tr>
  </tbody>
</table>
Try It Yourself

How It Works

  1. Open <thead> for the header group.
  2. Add one <tr> of <th> column titles.
  3. Put data in <tbody> so body rows stay separate.
  4. Style thead without touching data cells.

Example 2 — scope on Header Cells

Mark each column header with scope="col" for clearer accessibility.

HTML
<table>
  <thead>
    <tr>
      <th scope="col">Item</th>
      <th scope="col">Cost</th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <th scope="row">Snacks</th>
      <td>40</td>
    </tr>
    <tr>
      <th scope="row">Travel</th>
      <td>120</td>
    </tr>
  </tbody>
</table>
Try It Yourself

How It Works

  1. Keep titles in thead with <th>.
  2. Set scope="col" on each column header.
  3. Optional row headers in the body use scope="row".
  4. Assistive tech can announce the right header for each cell.

Example 3 — Multi-row thead

Use two header rows with colspan and rowspan so columns still line up.

HTML
<table>
  <thead>
    <tr>
      <th scope="col" rowspan="2">ID</th>
      <th scope="col" colspan="2">Student</th>
      <th scope="col" rowspan="2">Credits</th>
    </tr>
    <tr>
      <th scope="col">First</th>
      <th scope="col">Last</th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <td>101</td>
      <td>Ada</td>
      <td>Lovelace</td>
      <td>240</td>
    </tr>
  </tbody>
</table>
Try It Yourself

How It Works

  1. Put both header rows inside one thead (still only one head group).
  2. rowspan="2" makes ID and Credits cover both header rows.
  3. colspan="2" makes Student cover First and Last.
  4. Keep the column count equal in every body row.

Example 4 — thead with tbody and tfoot

Use all three section groups for head, data, and total.

HTML
<table>
  <caption>Council budget</caption>
  <thead>
    <tr>
      <th scope="col">Item</th>
      <th scope="col">Cost</th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <th scope="row">Stationery</th>
      <td>18,000</td>
    </tr>
    <tr>
      <th scope="row">Snacks</th>
      <td>3,000</td>
    </tr>
  </tbody>
  <tfoot>
    <tr>
      <th scope="row">Totals</th>
      <td>21,000</td>
    </tr>
  </tfoot>
</table>
Try It Yourself

How It Works

  1. caption names the table.
  2. thead holds column labels; tbody holds items.
  3. tfoot holds the total after the body.
  4. Semantics help screen readers, CSS, and multi-page print layouts.

Edge Cases & Pitfalls

Most thead mistakes are order rules, duplicate heads, or weak header cells.

limits

Only one thead per table

Put every header row inside that single group. Do not stack multiple thead elements.

order

Place head before body

After caption/colgroup: thead, then tbody / tfoot. Keep that order in the markup.

cells

Prefer th in the head

Column titles belong in <th>, not bold td cells, so assistive tech can treat them as headers.

spans

Keep multi-row math valid

With colspan/rowspan, every body row must still match the full column count.

attrs

Skip deprecated align / bgcolor

Style the head with CSS. Presentational attributes on thead are obsolete.

Browser Support

The <thead> element is core HTML table markup in every browser. It is not a Node.js, Deno, or Bun API.

✓ Baseline · Widely available

<thead>

Widely available since about July 2015 (and long before). Grouping header rows helps CSS, accessibility, and multi-page printing.

98% Global support (approx.)
Google Chrome All
Full support
Mozilla Firefox All
Full support
Apple Safari All
Full support
Microsoft Edge All
Full support
Opera All
Full support
Samsung Internet All
Full support
Internet Explorer All
Supported
<thead> Widely supported

Bottom line: Safe to use for column header groups. Prefer one thead with th cells, place it before tbody, and style with CSS.

Key Takeaways

  • Role: <thead> groups the table’s header rows.
  • Cells: put column titles in <th> (often with scope="col").
  • Limit: only one thead; multiple tr rows are fine inside it.
  • Order: after caption/colgroup, before tbody and tfoot.

One line: put column header rows in a single <thead> before your data rows.

Default CSS Settings

Typical user-agent styling for thead (simplified; exact rules vary by browser):

default.css
thead {
  display: table-header-group;
  vertical-align: middle;
  border-color: inherit;
}

Style head cells with selectors like thead th. When printing long tables, browsers may repeat the head on each page.

Frequently Asked Questions

The thead element groups the header rows of a table — usually column titles made with th. It works with tbody and tfoot to mark clear table sections.
No. Simple tables can use only table, tr, th, and td. Use thead when you want a clear header group for styling, printing, and accessibility.
No. A table may have only one thead (and only one tfoot). You can have multiple consecutive tbody sections.
Inside table, after any caption and colgroup, and before tbody, tfoot, and bare tr rows.
Yes. Put multiple tr elements inside thead for multi-level headers. Use colspan and rowspan on th so columns line up.
No. Those attributes are deprecated. Style the header with CSS such as background-color, text-align, and vertical-align.

Next: time

Mark dates and times in a machine-readable way.

time tutorial →

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.

12 people found this page helpful