"> " />
Easy Tutorial
❮ Tag Body Html Elements ❯

HTML <th> Tag

Example

A simple HTML table with two header cells and two data cells:

<table border="1">
    <tr>
        <th>Month</th>
        <th>Savings</th>
    </tr>
    <tr>
        <td>January</td>
        <td>$100</td>
    </tr>
</table>

Browser Support

All major browsers support the <th> tag.


Tag Definition and Usage

The <th> tag defines a header cell in an HTML table.

There are two types of cells in an HTML table:

Text in <th> elements are typically rendered in bold and centered.

Text in <td> elements are typically rendered as normal 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 that were supported 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 <br>right <br>center <br>justify <br>char Not supported in HTML5. Specifies the horizontal alignment of content in a header cell.
axis category_name Not supported in HTML5. Categorizes header cells.
bgcolor rgb(x,x,x)<br>#xxxxxx<br>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 the character to align the content on.
charoff number Not supported in HTML5. Specifies the offset of the alignment character.
colspan number Specifies the number of columns a header cell should span.
headers header_id Specifies one or more header cells a header cell is related to.
height pixels<br>% 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 inside a header cell should wrap.
rowspan number Specifies the number of rows a header cell should span.
scope col <br>colgroup <br>row <br>rowgroup Specifies whether a header cell is a header for a column, row, or group of columns or rows.
valign top <br>middle <br>bottom <br>baseline Not supported in HTML5. Specifies the vertical alignment of content in a header cell.
width pixels<br>% Not supported in HTML5. Deprecated in HTML 4.01. Specifies the width of a header cell.

Global Attributes

The <th> tag supports HTML's global attributes.


Event Attributes

The <th> tag supports all HTML's event attributes.


Try It - Examples

Table Headers

Empty Cells Table with Caption

Table Tags

Table Cells Spanning Rows or Columns


Related Articles

HTML Tutorial: HTML Tables

HTML DOM Reference: Th Object

❮ Tag Body Html Elements ❯