<th> (Table Header)
This element specifies a header cell in a table. The element should occur within a table row as defined by a tr element. The main difference between this element and td is that browsers might render table headers slightly differently, usually bolding and centering contents. However, the element is logical in nature and should be used to structure tables.
align="center | justify | left | right"
bgcolor="color name | #RRGGBB" (transitional only)
dir="ltr | rtl"
headers="space-separated list of associated header
cells' id values"
height="pixels" (transitional only)
id="unique alphanumeric identifier"
nowrap="nowrap" (transitional only)
scope="col | colgroup | row | rowgroup"
valign="baseline | bottom | middle | top"
width="pixels" (transitional only)
Nonstandard Attributes Commonly Supported
background="url of image file"
bordercolor="color name | #RRGGBB"
Attributes Defined by Internet Explorer
bordercolordark="color name | #RRGGBB" (4)
bordercolorlight="color name | #RRGGBB" (4)
hidefocus="true | false" (5.5)
Standard Event Attributes
onclick, ondblclick, onkeydown, onkeypress, onkeyup, onmousedown, onmousemove, onmouseout, onmouseover, onmouseup
Events Defined by Internet Explorer
onactivate, onbeforeactivate, onbeforecopy, onbeforecut, onbeforedeactivate,onbeforeeditfocus, onbeforepaste, onblur, oncontextmenu, oncontrolselect, oncopy, oncut, ondeactivate, ondrag, ondragend, ondragenter, ondragleave, ondragover, ondragstart, ondrop, onfilterchange, onfocus, onfocusin, onfocusout, onhelp, onlosecapture, onmouseenter, onmouseleave, onmousewheel, onmove, onmoveend, onmovestart, onpaste, onpropertychange, onreadystatechange, onresizeend, onresizestart, onselectstart, ontimeerror
Element Specific Attributes
- The value of this attribute is an abbreviated name for a header cell. This might be useful when attempting to display large tables on small screens.
- This attribute is used to align the contents of the cells within the <tbody> element. Common values are center, justify, left, and right.
- This attribute is used to provide a name for a group of related headers.
- This nonstandard attribute, which is supported by Internet Explorer, Netscape and WebTV, specifies the URL of a background image for the table cell. The image is tiled if it is smaller than the cell's dimensions.
- This attribute specifies a background color for a table cell. Its value can be either a named color, such as red, or a color specified in the hexadecimal #RRGGBB format, such as #FF0000.
- This attribute, supported by Internet Explorer and Netscape, is used to set the border color for a table cell. The attribute should be used only with a positive value for the border attribute. The value of the attribute can be either a named color, such as green, or a color specified in the hexadecimal #RRGGBB format, such as #00FF00.
- This Internet Explorer-specific attribute specifies the darker of two border colors used to create a three-dimensional effect for a cell's borders. It must be used with the border attribute set to a positive value. The attribute value can be either a named color, such as blue, or a color specified in the hexadecimal #RRGGBB format, such as #00FF00).
- This Internet Explorer-specific attribute specifies the lighter of two border colors used to create a three-dimensional effect for a cell's borders. It must be used with the border attribute set to a positive value. The attribute value can be either a named color, such as red, or a color specified in the hexadecimal #RRGGBB format, such as #FF0000.
- This attribute is used to define the character to which element contents are aligned when the align attribute is set to the char value.
- This attribute contains an offset as a positive or negative integer to align characters as related to the char value. A value of 2, for example, would align characters in a cell two characters to the right of the character defined by the char attribute.
- This attribute takes a numeric value that indicates how many columns wide a cell should be. This is useful to create tables with cells of different widths.
- This attribute takes a space-separated list of id values that correspond to the header cells related to this cell.
- This attribute indicates the height in pixels of the header cell.
- This attribute keeps the content within a table header cell from automatically wrapping.
- This attribute takes a numeric value that indicates how many rows high a table cell should span. This attribute is useful in defining tables with cells of different heights.
- This attribute specifies the table cells for which the current cell provides header information. A value of col indicates that the cell is a header for the the rest of the column below it. A value of colgroup indicates that the cell is a header for its current column group. A value of row indicates that that the cell contains header information for the rest of the row it is in. A value of rowgroup indicates that the cell is a header for its row group. This attribute can be used in place of the header attribute and is useful for rendering assistance by nonvisual browsers. This attribute was added very late to the HTML 4.0 specification so support for this attribute is minimal.
- This attribute is used to set the vertical alignment for the table cell. HTML 4 defines baseline, bottom, middle, and top. Internet Explorer further defines center, which should act just like middle.
- This attribute specifies the width of a header cell in pixels.
HTML 3.2, 4, 4.01, XHTML 1.0, 1.1, Basic
Internet Explorer 2, 3, 4, 5, 5.5, 6
Netscape 1.1, 2, 3, 4, 4.5-4.8, 6, 7
The HTML 3.2 specification defines only align, colspan, height, nowrap, rowspan, valign, and width attributes.
This element should always be within the <tr> element.
Under the XHTML 1.0 specification, the closing </th> tag ceases to be optional.