Home > Abakada: Back to Basics > Language References > HTML Elements > TH Element
Denotes a table header cell.
HTML Syntax
<th
align = center | left | right
background = url
bgcolor = color
bordercolor = color
bordercolordark = color
bordercolorlight = color
class = classname
colspan = n
id = value
nowrap
rowspan = n
style = css_style_rules
title = text
valign = baseline | bottom | center | middle | top
>
The TH element specifies a table cell whose contents are used for column or row headings. TH elements can only be used inside table rows, or within a TR element.
Browsers usually display the content of TH elements centered within the cell, and in a bolder font than those of regular table cells.
Although the W3C specifies that TH end tags are optional and may be omitted, it is safer to always close table headers, as not all browsers support this recommendation, and may produce unexpected results.
A <th > element’s end tag can be omitted if the <th > element is immediately followed by a <td > or <th > element, or if there is no more content in the parent element.
The <th> element supports the following attributes, in addition to global attributes common to all HTML elements.
abbr | text | Specifies an abbreviated version of the content in a header cell |
colspan | number | Specifies the number of columns a header cell should span |
headers | header_id | Specifies one or more header cells a cell is related to |
rowspan | number | Specifies the number of rows a header cell should span |
scope | col, colgroup, row, rowgroup | Specifies whether a header cell is a header for a column, row, or group of columns or rows |
The following shows how the th element may be used.
<table>
<tr><th>This is the header row.</th></tr>
<tr><td>This is the first row.</td></tr>
<tr><td>This is the second row.</td></tr>
</table>
TABLE, TD, TR, Using Tables
|