Learning HTML 3.2 by Examples, section 5 Descriptions of HTML 3.2 tags:

TH - table heading (cell) (Not in HTML 2.0!)

Purpose

To present, within a table, a cell which acts as a (row or column) heading.

Typical rendering

A cell in a table, typically presented using some more prominent font such as boldface. By default, the data is centered within the space allocated for the cell by the browser.

Basic syntax

<TH>data</TH>

In principle, the end tag </TH> can always be omitted. This is not recommendable, since some browsers (including Netscape) may act incorrectly when the end tag is omitted.

Possible attributes

attribute name possible values meaning notes
NOWRAP NOWRAP suppress word wrap equivalent to using non-breaking spaces, &nbsp;, instead of normal spaces within the contents of the cell; this attribute is deprecated in HTML 4.0
ROWSPAN integer number of rows spanned by the cell default is 1
COLSPAN integer number of columns spanned by the cell default is 1
ALIGN LEFT, CENTER, RIGHT horizontal alignment of data in the cell default is CENTER or the ALIGN attribute in an enclosing TR element
VALIGN TOP, MIDDLE, BOTTOM vertical alignment of data in the cell overrides a VALIGN attribute in an enclosing TR element
WIDTH integer suggested width of the cell, in pixels the browser should use the value unless it conflicts with the width requirements for other cells in the same column; although many browsers also support percentage widths in this context, they do it rather inconsistently; and browsers implement even HTML 3.2 conformant WIDTH attributes differently in many cases, especially when you try to make some columns fixed width and other columns occupy the rest of the available total width; this attribute is deprecated in HTML 4.0
HEIGHT integer suggested height of the cell, in pixels the browser should use the value unless it conflicts with the height requirements for other cells in the same row; this attribute is deprecated in HTML 4.0

Allowed context

TR element.

Contents

Headings, text elements, block elements, and ADDRESS elements.

Examples

<TH>Sum</TH>

Notes

See the discussion of tables, which contains additional examples, too.

The TD and TH elements are very similar; in particular, they have the same attributes. The TD element is for data in a table whereas the TH element is for headings of columns or rows in a table. The visible differences are:

It is sometimes a matter of taste whether you use TD or TH especially as regards to the first column ( i.e. first element of each row).

Date of last update: 2010-12-16.
This page belongs to the free information site IT and communication, section Web authoring and surfing, by Jukka "Yucca" Korpela.