th

FilterElements

<th> ... </th>

Defines a table header cell. Table header cells provide important information and context to the table cells in the row or column that they precede. They are an important tool for making the information in tables accessible. In terms of markup, they function the same as table data cells (td).

Start/End Tags

HTML: Required/Optional;
XHTML: Required/Required

Specifications

  • HTML 4.01
  • HTML5

abbr=

Values: text
Not in HTML5. Provides an abbreviated form of the cell’s content.

align=

Values: left | right | center | justify | char
Not in HTML5. Specifies the horizontal alignment of text in a cell or cells. The default value is left.

axis=

Values: text
Not in HTML5. Places a cell into a conceptual category, which could then be used to organize or search the table in different ways.

bgcolor=

Values: #rrggbb or color name
Deprecated. Not in HTML5. Specifies a color to be used in the table cell. A cell’s background color overrides colors specified at the row or table levels.

char=

Values: character
Not in HTML5. Specifies a character along which the cell contents will be aligned when align is set to char. The default character is a decimal point (language-appropriate). This attribute is generally not supported by current browsers.

charoff=

Values: length
Not in HTML5. Specifies the offset distance to the first alignment character on each line. If a line doesn’t use an alignment character, it should be horizontally shifted to end at the alignment position. This attribute is generally not supported by current browsers.

colspan=

Values: number
Specifies the number of columns the current cell should span. The default value is 1. According to the HTML 4.01 specification, the value 0 (zero) means the current cell spans all columns from the current column to the last column in the table; in reality, however, this feature is not supported in current browsers.

headers=

Values: id reference
Lists header cells (by id) that provide header information for the current data cell. This is intended to make tables more accessible to nonvisual browsers.

height=

Values: pixels or percentage
Deprecated. Not in HTML5. Specifies the height of the cell in number of pixels or by a percentage value relative to the table height. The height specified in the first column will apply to the rest of the cells in the row. The height values need to be consistent for the cells in a particular row. Pixel measurements are more reliable than percentages, which work only when the height of the table is specified in pixels.

nowrap

Values: None in HTML. (nowrap="nowrap" in XHTML)
Deprecated. Not in HTML5. Disables automatic text wrapping for the current cell. Line breaks must be added with a br element or by starting a new paragraph.

rowspan=

Values: number
Specifies the number of rows spanned by the current cell. The default value is 1. According to the HTML 4.01 Recommendation, the value 0 (zero) means the current cell spans all rows from the current row to the last row; in reality, however, this feature is not supported by browsers.

scope=

Values: row | col | rowgroup | colgroup
Specifies the table cells for which the current cell provides header information. A value of col indicates that the current cell is the header for all the cells that fall below. colgroup indicates the current cell is the header for the column group that contains it. A value of row means that the current cell is the header for the cells in the rest of the row. A value of rowgroup means the current cell is the header for the containing row group. This is intended to make tables more accessible to nonvisual browsers.

valign=

Values: top | middle | bottom | baseline
Not in HTML5. Specifies the vertical alignment of text in the cells of a column.

width=

Values: pixels or percentage
Deprecated. Not in HTML5. Specifies the width of the cell in number of pixels or by a percentage value relative to the table width. The width specified in the first row will apply to the rest of the cells in the column, and the values need to be consistent for cells in the column.
<table>
<tr>
  <th>Planet</th>
  <th>
Distance from Earth</th>
</tr>
<tr>
  <td>Venus</td>
  <td>pretty darn far</td>
</tr>
<tr>
  <td>Neptune</td>
  <td>ridiculously far</td>
</tr>
</table>

Rendered Example

                 
PlanetDistance from Earth
Venuspretty darn far
Neptuneridiculously far

A gray background color was added to th and td elements to make their boundaries more evident.