HTML <th> Tag

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

Definition and Usage

The <th> element defines a table header cell. It must be a child of <tr> inside a <table>. Use it for column or row labels. Put data values in <td>.

Tell assistive technology what the header covers with scope (col, row, colgroup, or rowgroup). Span cells with colspan / rowspan, and use headers for complex associations. An optional abbr can give a short label for the header.

Baseline · Widely available.

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

Deprecated attributes.

Do not use align, axis, bgcolor, char, charoff, height, valign, or width on <th>. Prefer CSS, and use scope instead of axis.

HTML Syntax

syntax.html
<th scope=" col|row">label</th>

The start tag is required. The end tag may be omitted in some cases, but writing both is clearer. Content is flow content, without headings, sectioning content, header, or footer descendants.

Attributes

The attributes you will use most often on <th>:

AttributeDescriptionTry it
scopeWhich cells this header relates to: col, row, colgroup, rowgroupTry it
colspanHow many columns the header spans (default 1)Try it
rowspanHow many rows the header spans (default 1)Try it
abbrShort alternative label for the header (useful for screen readers)Try it
headersSpace-separated id list of related header cells (complex tables)See headers docs
bgcolorDeprecated — use CSS background-color insteadTry it

Also deprecated (do not use on new pages): align, axis, valign, width, height.

Global Attributes

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

Live Preview

Change a header label and its scope on a real table.

The first header cell is a real <th>. scope="col" is typical for top headers; row is shown for demos too.

Table
Match scores
PlayerScore
Ada92
Grace88

scope="col" · Player

HTML Examples

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

Example 1 — Column Headers

Mark the first row as column titles with <th>.

HTML
<table>
  <tr>
    <th scope="col">Player</th>
    <th scope="col">Score</th>
  </tr>
  <tr>
    <td>Ada</td>
    <td>92</td>
  </tr>
  <tr>
    <td>Grace</td>
    <td>88</td>
  </tr>
</table>
Try It Yourself

How It Works

  1. Put labels in <th> in the first row.
  2. Set scope="col" so each header relates to its column.
  3. Use <td> for the scores and names in data rows.
  4. Prefer real headers over styling a td to look bold.

Example 2 — Column and Row Headers

Use scope="col" on top headers and scope="row" on the first cell of each data row.

HTML
<table>
  <tr>
    <th scope="col">Symbol</th>
    <th scope="col">Code word</th>
  </tr>
  <tr>
    <th scope="row">A</th>
    <td>Alfa</td>
  </tr>
  <tr>
    <th scope="row">B</th>
    <td>Bravo</td>
  </tr>
</table>
Try It Yourself

How It Works

  1. scope="col" marks a header for the whole column.
  2. scope="row" marks a header for cells in that row.
  3. Simple tables can often infer scope, but setting it is clearer.
  4. Group with thead/tbody in larger tables when it helps structure.

Example 3 — colspan and rowspan

Span a header across columns or rows. Do not overlap cells.

HTML
<table>
  <tr>
    <th scope="col" rowspan="2">Symbol</th>
    <th scope="col" colspan="2">Pronunciation</th>
  </tr>
  <tr>
    <th scope="col">IPA</th>
    <th scope="col">Respelling</th>
  </tr>
  <tr>
    <th scope="row">A</th>
    <td>ˈælfa</td>
    <td>AL fah</td>
  </tr>
</table>
Try It Yourself

How It Works

  1. rowspan="2" makes Symbol cover both header rows.
  2. colspan="2" makes Pronunciation cover IPA and Respelling.
  3. Second header row fills the two free spots under Pronunciation.
  4. Keep the grid valid — never overlap spanned cells.

Example 4 — abbr on a Header

Provide a short alternative label when the visible header is long.

HTML
<table>
  <tr>
    <th scope="col" abbr="Qty">Quantity ordered</th>
    <th scope="col">Price</th>
  </tr>
  <tr>
    <td>12</td>
    <td>$4</td>
  </tr>
</table>
Try It Yourself

How It Works

  1. Keep a clear visible header for sighted users.
  2. Add abbr="…" with a short alternative when helpful.
  3. Some assistive tools may prefer the short form when announcing the cell.
  4. Do not rely on abbr alone — the visible text should still make sense.

Edge Cases & Pitfalls

Most th mistakes are fake headers, missing scope, or overlapping spans.

semantics

Do not fake headers with bold td

Screen readers need real <th> cells. Visual boldness is not enough.

scope

Prefer explicit scope

Inference works in simple tables, but scope="col" / scope="row" is clearer and more reliable.

spans

Never overlap cells

colspan / rowspan must leave a valid grid. Overlaps are invalid.

complex

Use headers for multi-level heads

When scope alone is not enough, link cells with id + headers, or split into simpler tables.

attrs

Skip presentational attributes

width, align, and bgcolor are deprecated. Style headers with CSS.

Browser Support

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

✓ Baseline · Widely available

<th>

Widely available since about July 2015 (and long before). scope, colspan, rowspan, abbr, and headers are broadly supported. Presentational attributes are obsolete.

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
<th> Widely supported

Bottom line: Safe to use for table headers. Prefer real th cells with clear scope, keep spans simple, and style with CSS.

Key Takeaways

  • Role: <th> marks a header for related table cells.
  • vs td: labels → th; values → td.
  • scope: use col / row (and groups when needed).
  • Spans: colspan / rowspan without overlapping cells.

One line: put column and row labels in <th> with a clear scope, and keep data in <td>.

Default CSS Settings

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

default.css
th {
  display: table-cell;
  vertical-align: inherit;
  font-weight: bold;
  text-align: center;
  padding: 1px;
}

Many designs set text-align: left on headers and add borders with border-collapse: collapse on the table.

Frequently Asked Questions

The th element is a table header cell. Use it for column or row labels so browsers and screen readers treat those cells as headings for related data.
th is a header cell. td is a normal data cell. Bold text inside a td is not a real header for accessibility.
scope tells which cells the header relates to: col for a column, row for a row, and colgroup or rowgroup for a group. Specifying it helps assistive technology.
In simple tables browsers often infer scope, but setting scope="col" or scope="row" is a clear, recommended habit.
In complex tables with multi-level headers, give each th an id and list related ids in the headers attribute on related cells.
No. th is only valid as a child of tr inside a table.

Next: thead

Group one or more header rows at the top of a table.

thead 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