View video tutorial

HTML <th> Tag

HTML

The <th> element defines a cell as the title of a group of table cells.

HTML <th> Tag


An HTML table contains two types of cells. Header cells defined by <th> element and Data cells defined by <td> element.

The top heading row <tr> represents the header that contain cells <th> for the table column name.

The <th> elements must be inside the <tr> element to create column headings.

The <td> element represents a cell in a table that contains data.

Element Attributes

Attribute Value Description
abbr text This specifies a short abbreviated description of the cell's content.
colspan number This specifies how many columns the header cell extends.
headers header_id This attribute contains a list of strings corresponding to the id attribute of the th elements.
rowspan number This specifies how many rows the header cell extends.
scope col
colgroup
row
rowgroup
This specifies the cells that the header (defined in the th) element relates to.

Global attributes

Global attributes may be applied on all elements, although some elements may have no effect on them.

<accesskey>, <class>, <contenteditable>, <contextmenu>, <data-*>, <dir>, <draggable>, <dropzone>, <hidden>, <id>, <lang>, <spellcheck>, <style>, <tabindex>, <title>, <translate>.

Learning with HTML Editor "Try it Now"

You can edit the HTML code and view the result using online editor.

Example

<tr>
    <th>First Name</th>
    <th>Last Name</th>
    <th>Job ID</th>
    <th>Salary</th>
</tr>
Try it Now »

Click on the "Try it Now" button to see how it works.