👀 Live Preview
Table with th column headers in thead and td data in tbody:
| Name | Age | Role |
|---|---|---|
| Alice | 28 | Designer |
| Bob | 32 | Developer |

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.
Column & row labels.
Group header rows.
Span columns.
Accessibility hook.
Headers vs data.
Semantic tables.
<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.
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.
Wrap header text between opening and closing th tags inside a tr row:
<th>Your Header Content</th><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>th must be a direct child of tr, inside table, thead, tbody, or tfoot.thead for clear semantic structure.scope="col" for column headers and scope="row" for row headers.colspan and rowspan to merge header cells across columns or rows.| Topic | Code Snippet | Notes |
|---|---|---|
| Basic th | <th>...</th> | Header cell |
| Column header | scope="col" | In thead |
| Row header | scope="row" | In tbody |
| colspan | <th colspan="2"> | Merge columns |
| vs td | th = header | td = data |
| Browser support | Universal | All browsers |
<th> vs <td>| Element | Purpose | Typical placement |
|---|---|---|
<th> | Header cell (column/row label) | thead or row headers |
<td> | Data cell (table data) | tbody rows |
| Default style | Bold, centered in many browsers | Normal weight text |
| Accessibility | Announced as column/row header | Announced as table cell |
The <th> tag supports colspan, rowspan, scope, and global HTML attributes.
<th colspan="2">Spanning Two Columns</th>
<th rowspan="3">Spanning Three Rows</th>
<th scope="col">Product</th>colspan SpanningNumber of columns the header cell spans horizontally.
colspan="2"rowspan SpanningNumber of rows the header cell spans vertically.
rowspan="3"scope A11yDeclares whether the header labels a column, row, or group (col, row, colgroup, rowgroup).
scope="col"abbr OptionalShort form of a long header label for screen readers and tooltips.
abbr="Qty"class / id GlobalHook for CSS to style header cells distinctly from data cells.
class="table-header"align / bgcolor ObsoleteDeprecated presentational attributes. Use CSS on th instead.
background: #f1f5f9Basic column headers, spanning attributes, and multi-level header layouts with copy-ready code and live previews.
Table with th column headers in thead and td data in tbody:
| Name | Age | Role |
|---|---|---|
| Alice | 28 | Designer |
| Bob | 32 | Developer |
Use <th> to label columns and rows, build complex header layouts, and improve table accessibility.
The primary purpose of th is defining header cells that label each column:
<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>Use colspan and rowspan on th to create merged header cells:
<tr>
<th colspan="2">Spanning Two Columns</th>
<th rowspan="3">Spanning Three Rows</th>
</tr>Combine colspan with multiple header rows for grouped column labels:
<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>th cells in thead so assistive tech recognizes header rows.scope="col" or scope="row" on th to clarify what each header labels.<th scope="row"> instead of td.abbr attribute provides a short spoken form for verbose headers.caption describes the table purpose before users read individual headers.Column or row labels go in th inside tr rows, usually in thead.
th is rendered as a header cell—typically bold—and associated with data cells.
scope and table structure help screen readers announce which header applies to each cell.
Users understand what each column and row represents in your tabular data.
The <th> tag is supported in all major browsers, including Internet Explorer.
All browsers render <th> as the standard table header cell.
Bottom line: Use <th> confidently for table headers in any browser.
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.
thead with th cellsscope on headers for accessibilityth with CSS to make headers visually distinctcolspan and rowspan for complex header layoutstd for column labels when th is appropriateth markupalign or bgcolor attributes<th>Bookmark these before you build your next HTML table.
Column labels.
PurposeGroup headers.
StructureMerge cells.
LayoutHeader vs data.
ComparisonA11y attribute.
AccessibilityAll browsers.
Compatibilityth is for header labels. td is for data values in table body rows.thead. Use th scope="row" in tbody for row headers.th labels a column (col), row (row), or a group of columns or rows.Practice <th> with thead, scope, and colspan in the Try It editor.
6 people found this page helpful