HTML <th> Tag

❮ Previous Reference Next ❯

Example

<table>
  <tr>
    <th>Heading</th>
    <th>Heading</th>
  </tr>
  <tr>
    <td>Table data</td>
    <td>Table data</td>
  </tr>
  <tr>
    <td>Foot data</td>
    <td>Foot data</td>
  </tr>
</table>

Meaning

The <th> element specifies a header cell in a table. The element should occur within a table row as defined by a <tr>tr element.

The difference between <th> element and <td> is that browsers might render table headers slightly differently, usually bolding and centering contents.

The element is logical in nature and should be used to structure tables.

Notes:

Version: HTML 3.2, 4, 4.01, 5


Standard Syntax

<th>...</th>



Browser Support




Status







Attributes

Attribute Value Description
abbr text Specifies a short abbreviation of the cell's content.
colspan number This attribute gives the number of columns respectively that the cell is to span.
headers headerId The value of this attribute must have the value of an id attribute of the th element that is targeted.
rowspan number Specifies the number of rows respectively that the cell is to span.
scope col
colgroup
row
rowgroup
Specifies whether a header cell is a header for a column, row, or group of columns or rows



Global Attributes

The <th> element also supports the Global Attributes in HTML.


Event Attributes

The <th> element also supports the Event Attributes in HTML.




By Default CSS Value(s)

Most of the browsers will display the <th> element with the following by default value(s)

th {
  display: table-cell;
  vertical-align: inherit;
  font-weight: bold;
  text-align: center;
}
❮ Previous Reference Next ❯