HTML <th> Tag

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

What You’ll Learn

The <th> tag defines header cells that label table columns and rows. This guide covers syntax, colspan and rowspan, scope, th vs td, accessibility, and best practices for beginners.

01

Header Cells

Column & row labels.

02

thead

Group header rows.

03

colspan

Span columns.

04

scope

Accessibility hook.

05

th vs td

Headers vs data.

06

Best Practices

Semantic tables.

What Is the <th> Tag?

The <th> tag is an HTML element used inside <tr> to define a table header cell. It stands for “table header” and labels columns or rows, giving context to the data in neighboring td cells.

Valid HTML5 — Header Cell

th marks header content. Browsers typically render it bold and centered. Screen readers announce it as a column or row header when used correctly.

Place column headers in thead and data in tbody with td. Use th with scope="row" inside tbody when the first cell in a row is a row header.

📝 Syntax

Wrap header text between opening and closing th tags inside a tr row:

syntax.html
<th>Your Header Content</th>

Inside thead Example

thead-th.html
<table>
  <thead>
    <tr>
      <th scope="col">Name</th>
      <th scope="col">Age</th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <td>John</td>
      <td>25</td>
    </tr>
  </tbody>
</table>

Syntax Rules

  • th must be a direct child of tr, inside table, thead, tbody, or tfoot.
  • Place column headers in thead for clear semantic structure.
  • Use scope="col" for column headers and scope="row" for row headers.
  • Use colspan and rowspan to merge header cells across columns or rows.
  • Style headers with CSS instead of obsolete presentational attributes.

⚡ Quick Reference

TopicCode SnippetNotes
Basic th<th>...</th>Header cell
Column headerscope="col"In thead
Row headerscope="row"In tbody
colspan<th colspan="2">Merge columns
vs tdth = headertd = data
Browser supportUniversalAll browsers

⚖️ <th> vs <td>

ElementPurposeTypical placement
<th>Header cell (column/row label)thead or row headers
<td>Data cell (table data)tbody rows
Default styleBold, centered in many browsersNormal weight text
AccessibilityAnnounced as column/row headerAnnounced as table cell

🧰 Attributes

The <th> tag supports colspan, rowspan, scope, and global HTML attributes.

attributes.html
<th colspan="2">Spanning Two Columns</th>
<th rowspan="3">Spanning Three Rows</th>
<th scope="col">Product</th>
colspan Spanning

Number of columns the header cell spans horizontally.

colspan="2"
rowspan Spanning

Number of rows the header cell spans vertically.

rowspan="3"
scope A11y

Declares whether the header labels a column, row, or group (col, row, colgroup, rowgroup).

scope="col"
abbr Optional

Short form of a long header label for screen readers and tooltips.

abbr="Qty"
class / id Global

Hook for CSS to style header cells distinctly from data cells.

class="table-header"
align / bgcolor Obsolete

Deprecated presentational attributes. Use CSS on th instead.

background: #f1f5f9

Examples Gallery

Basic column headers, spanning attributes, and multi-level header layouts with copy-ready code and live previews.

👀 Live Preview

Table with th column headers in thead and td data in tbody:

NameAgeRole
Alice28Designer
Bob32Developer

📚 Common Use Cases

Use <th> to label columns and rows, build complex header layouts, and improve table accessibility.

Basic Table Header

The primary purpose of th is defining header cells that label each column:

basic-table-header.html
<table>
  <thead>
    <tr>
      <th scope="col">Header 1</th>
      <th scope="col">Header 2</th>
      <th scope="col">Header 3</th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <td>Data 1</td>
      <td>Data 2</td>
      <td>Data 3</td>
    </tr>
  </tbody>
</table>
Try It Yourself

Spanning Columns and Rows

Use colspan and rowspan on th to create merged header cells:

spanning-columns-and-rows.html
<tr>
  <th colspan="2">Spanning Two Columns</th>
  <th rowspan="3">Spanning Three Rows</th>
</tr>
Try It Yourself

Multi-Level Headers

Combine colspan with multiple header rows for grouped column labels:

multi-level-headers.html
<thead>
  <tr>
    <th colspan="2">Header 1 and 2</th>
    <th>Header 3</th>
  </tr>
  <tr>
    <th>Subheader 1</th>
    <th>Subheader 2</th>
    <th>Subheader 3</th>
  </tr>
</thead>
Try It Yourself

♿ Accessibility

  • Use thead for column headers — Group th cells in thead so assistive tech recognizes header rows.
  • Add scope — Use scope="col" or scope="row" on th to clarify what each header labels.
  • Row headers in tbody — When the first cell labels a row, use <th scope="row"> instead of td.
  • Use abbr for long labels — The abbr attribute provides a short spoken form for verbose headers.
  • Add a caption — A caption describes the table purpose before users read individual headers.

🧠 How <th> Works

1

Author adds header cells

Column or row labels go in th inside tr rows, usually in thead.

Markup
2

Browser marks headers

th is rendered as a header cell—typically bold—and associated with data cells.

Rendering
3

Assistive tech reads scope

scope and table structure help screen readers announce which header applies to each cell.

A11y
=

Accessible table headers

Users understand what each column and row represents in your tabular data.

Browser Support

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

Baseline · HTML4 / HTML5

Table headers everywhere

All browsers render <th> as the standard table header cell.

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
<th> tag 100% supported

Bottom line: Use <th> confidently for table headers in any browser.

Conclusion

The <th> tag is essential for well-organized, accessible HTML tables. By labeling columns and rows with semantic header cells, you help every user understand your tabular data at a glance.

💡 Best Practices

✅ Do

  • Wrap column headers in thead with th cells
  • Add scope on headers for accessibility
  • Style th with CSS to make headers visually distinct
  • Use colspan and rowspan for complex header layouts

❌ Don’t

  • Use td for column labels when th is appropriate
  • Rely on bold styling alone without semantic th markup
  • Use obsolete align or bgcolor attributes
  • Skip headers in data tables that need context

Key Takeaways

Knowledge Unlocked

Six truths every developer should know about <th>

Bookmark these before you build your next HTML table.

6
Core concepts
📑 02

thead

Group headers.

Structure
📐 03

colspan

Merge cells.

Layout
⚖️ 04

vs td

Header vs data.

Comparison
05

scope

A11y attribute.

Accessibility
🌐 06

100% Support

All browsers.

Compatibility

❓ Frequently Asked Questions

It defines header cells that label table columns or rows, helping users and assistive technologies understand the data.
th is for header labels. td is for data values in table body rows.
Yes. Place column headers in thead. Use th scope="row" in tbody for row headers.
It tells assistive tech whether a th labels a column (col), row (row), or a group of columns or rows.
Yes. Full support in every major browser including Internet Explorer.

Build accessible table headers

Practice <th> with thead, scope, and colspan in the Try It editor.

Try basic headers 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