HTML <th> Tag

Advertisements


Description

The HTML <th> tag is used for specifying a header cell or table header within a table.

Example

<!DOCTYPE html>
<html>
<head>
<title>HTML th Tag</title>
</head>
<body>
<table border="1">
  <tr>
    <th>ID</th>
    <th>Product Details</th>
  </tr>
  <tr>
    <td>00L1</td>
    <td>i3, 500gb laptop</td>
  </tr>
</table>
</body>
</html>

This will produce following result:

ID Product Details
00L1 i3, 500gb laptop

Global Attributes

This tag supports all the global attributes described in - HTML Attribute Reference

Specific Attributes

The HTML <th> tag also supports following additional attributes:

AttributeValueDescription
abbr abbreviated_textDeprecated-Specifies an abbreviated version of the content in a header cell.
align right
left
center
justify
char
Deprecated-Content alignment in header cell.
axis nameDeprecated-Specifies a category for this th.
bgcolor rgb(x,x,x)
#hexcode
colorname
Deprecated-Specifies the background color of the header cell.
charcharacterDeprecated-Specifies which character to align text on. Used when align="char"
charoff pixels or %Deprecated-Specifies an alignment offset (either in pixels or percentage value) against the first character as specified with the char attribute. Used when align="char"
colspan numberSpecifies the number of columns the header cell spans across.
headers idSpecifies one or more header cells a cell is related to.
heightpixelsDeprecated-Specifies the height of the header cell.
nowrap nowrapDeprecated-Prevents text from automatically wrapping.
rowspan numbersSpecifies the number of rows the header cell spans across.
scope col
colgroup
row
rowgroup
This attribute is used on header cells and specifies the cells that will use this header's information.
valign top
middle
bottom
baseline
Deprecated-Vertical alignment.
width pixels or %Deprecated-Specifies the width of the header cell

Event Attributes

This tag supports all the event attributes described in - HTML Events Reference

Browser Support

ChromeFirefoxIEOperaSafariAndroid
YesYesYesYesYesYes

html_tags_reference.htm

Advertisements