Description

The <th> tag defines a header cell in a table. A Table cells may contain two types of information: header information and data.

  • The <th> (short for table head) tag defines a cell that contains header information.
  • The <td> tag defines a cell that contains data.

This distinction enables web browser to render header and data cells distinctly, even in the absence of style sheets. For example, header cell text rendered with a bold font while text inside the data cell rendered as a regular text.

The following table summarizes the usages context and the version history of this tag.

Parent:<tr>
Content:Block, inline and text
Start/ End Tag:Start tag: required, End tag: optional
Version:HTML 3.2, 4, 4.01, 5

Syntax

The basic syntax of the <th> tag is given with:

HTML/XHTML: <th> ... </th>

The example below shows the <th> tag in action.

<table>
    <tr>
        <th>No.</th>
        <th>Name</th>
        <th>Email</th>
    </tr>
    <tr>
        <td>1</td>
        <td>John Carter</td>
        <td>johncarter@mail.com</td>
    </tr>
    <tr>
        <td>2</td>
        <td>Peter Parker</td>
        <td>peterparker@mail.com</td>
    </tr>
    <tr>
        <td>3</td>
        <td>John Rambo</td>
        <td>johnrambo@mail.com</td>
    </tr>
</table>

Tag-Specific Attributes

The following table shows the attributes that are specific to the <th> tag.

Global Attributes

Like all other HTML tags, the <th> tag supports the global attributes in HTML5.

Event Attributes

The <th> tag also supports the event attributes in HTML5.

Browser Compatibility

Element
<th>YesYesYesYesYes