HTML

th Tag in HTML

Example

A simple HTML table with three rows, two header cells and four data cells:
				
					<table>
  <tr>
    <th>Month</th>
    <th>Savings</th>
  </tr>
  <tr>
    <td>January</td>
    <td>$100</td>
  </tr>
  <tr>
    <td>February</td>
    <td>$80</td>
  </tr>
</table>
				
			

Definition and Usage

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

An HTML table has two kinds of cells:

  • Header cells – contains header information (created with the <th> element)
  • Data cells – contains data (created with the <td> element)

The text in <th> elements are bold and centered by default.

The text in <td> elements are regular and left-aligned by default.

Attributes

AttributeValueDescription
abbrtextSpecifies an abbreviated version of the content in a header cell
colspannumberSpecifies the number of columns a header cell should span
headersheader_idSpecifies one or more header cells a cell is related to
rowspannumberSpecifies the number of rows a header cell should span
scopecol
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> tag also supports the Global Attributes in HTML.


Event Attributes

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

Related Articles