Signup/Sign In

HTML TH Tag

In HTML, the <th> tag is used to define one cell as a header of a group of cells.

  • There are two kinds of cells in an HTML table one kind of cell is used as a header for the group of cells and another kind i.e standard cells contains data for a table.

  • The text between the starting and ending of <th> tags are bold and centered by default.

  • The <th> tag is the child tag of the table tag.

HTML <th> Tag Syntax and Usage

The <th> tag requires the start(opening) tag and end(closing) tag.

Following is the syntax for using the <th> tag in your HTML code:

<table>
<th>
..content here
</th>
</table>

HTML <th> Tag Attributes

The <th> tag supports both global and event attributes and some of the common attributes are given below.

1. Abbr

This attribute is used to define the short abbreviation for the content of the cell.

2. Colspan

The value of this attribute is a non-negative integer that indicates how many columns the cell extends. Its default value is 1.

3. Rowspan

The value of this attribute is a non-negative integer that indicates how many columns the cell extends. Its default value is 1.

4. Scope

This enumerated attribute defines the cells that the header tag relates to; It has values: row, col, auto,rowgroup, colgroup.

5. Header

It is used to specify that one or more header cells a cell relates to.

HTML <th> Tag Basic Example

Below we have a basic example showing how we use the HTML <th> tag.

Default CSS settings for HTML <th> Tag

th {
  display: table-cell;
  vertical-align: inherit;
  font-weight: bold;
  text-align: center;
}

Browser Support for HTML <th> Tag

Following browsers support this attribute:

  • Google Chrome 6.0+

  • Internet Explorer 9.0+

  • Firefox 4+

  • Opera 11.1+

  • Safari 5.0+



About the author:
Aspiring Software developer working as a content writer. I like computer related subjects like Computer Networks, Operating system, CAO, Database, and I am also learning Python.