The <th> Tag in HTML 5

The <th> tag for table heading cells

The <th> table heading cell tag divides a table row into individual cells, like the <td> table detail cell tag, but is used for headings in a table. A column heading is usually included above a column in a table and can span multiple columns of the table, but other headings may appear elsewhere, such as the row headings in the example HTML table below. The style of a heading may be different from the rest of the cells in the same column or row - for example, by default the text is centered. In the table example below, there are three column headings and two row headings created by the <th> tag.

HTML <table> Demo
Table Caption
→Multiple Column Heading←
→First Column Heading← →Second Column Heading←
This is an example of an HTML table footer.
→Row 1← Row 1 Column 1 Row 1 Column 2
→Row 2← Row 2 Column 1 Row 2 Column 2

This is an actual working demo of the table heading example code below. (Do View Source to verify that this page is using the HTML 5 DOCTYPE. You can also verify it is Valid HTML 5 using the HTML Validator. Try using it to validate URLs with HTML examples from other places that claim to be HTML 5 web sites!)

The <th> tag is similar to the <td> tag in that both can be used within a tr element. One important difference, however, is that while the <td> tag is one of the sectioning root tags, which starts a new section outline for the content of the td element, the <th> tag is not and therefore contributes to the same section outline as its ancestors.

See the tutorial on Creating HTML Tables for full details on how to create an HTML table using the HTML table tags together.