HTML <th>Tag
Examples
A simple HTML table with two header cells and two data cells:
Try it Yourself »
(See more examples at the bottom of the page)
Browser Support
![]()
![]()
![]()
![]()
![]()
All major browsers support the <th> tag.
Tag Definition and Usage Instructions
The <th> tag defines a header cell in an HTML table.
An HTML table has two kinds of cells:
- Header cells - contain header information (created by the <th> element)
- Standard cells - contain data (created by the<td>element)
Text in <th> elements is usually bold and centered.
Text in <td> elements is usually regular left-aligned text.
Tips and Notes
Tip:If you need to span content across multiple rows or columns, use the colspan and rowspan attributes!
Differences Between HTML 4.01 and HTML5
Some attributes in HTML 4.01 are no longer supported in HTML5.
Attributes
| Attribute | Value | Description |
|---|---|---|
| abbr | text | Not supported in HTML5.Specifies an abbreviated version of the content in a header cell. |
| align | left right center justify char |
Not supported in HTML5.Specifies the horizontal alignment of the content in a header cell. |
| axis | category_name | Not supported in HTML5.Categorizes header cells. |
| bgcolor | rgb(x,x,x) #xxxxxx colorname |
Not supported in HTML5. Deprecated in HTML 4.01.Specifies the background color of a header cell. |
| char | character | Not supported in HTML5.Specifies which character to use to align the content. |
| charoff | number | Not supported in HTML5.Specifies the offset of the alignment character. |
| colspan | number | Specifies the number of columns a header cell can span. |
| headers | header_id | Specifies one or more header cells associated with the header cell. |
| height | pixels % |
Not supported in HTML5. Deprecated in HTML 4.01.Specifies the height of a header cell. |
| nowrap | nowrap | Not supported in HTML5. Deprecated in HTML 4.01.Specifies whether the content in a header cell should wrap. |
| rowspan | number | Specifies the number of rows a header cell can span vertically. |
| scope | col colgroup row rowgroup |
Specifies whether a header cell is a header for a row, column, row group, or column group. |
| valign | top middle bottom baseline |
Not supported in HTML5.Specifies the vertical alignment of the content in a header cell. |
| width | pixels % |
Not supported in HTML5. Deprecated in HTML 4.01.Specifies the width of a header cell. |
Global Attributes
The <th> tag supports theHTML Global Attributes。
Event Attributes
The <th> tag supports allHTML Event Attributes。
Try it Yourself - Examples
Headers in a Table
This example demonstrates how to display table headers.
Empty Cells
This example demonstrates how to use " " to handle cells without content.
Table with a Caption
This example demonstrates a table with a caption.
Tags Inside a Table
This example demonstrates how to display elements inside other elements.
Table Cells Spanning Rows or Columns
This example demonstrates how to define table cells that span rows or columns.
Related Articles
HTML Tutorial:HTML Tables
HTML DOM Reference:Th Object
Other Extensions