This stands for table header. Header cells are identical to data cells in all respects, with the exception that header cells are in a bold font, and have a default ALIGN=center
.
<TH ...> ... </TH>
can contain the following attributes:
ALIGN="left|center|right"
This attribute controls whether text inside the table header is aligned to the left, right or centred within the cell.
VALIGN="top|middle|bottom|baseline"
The VALIGN
attribute controls whether text inside the table header is aligned to the top, bottom, or vertically centred within the cell.
WIDTH="value_or_percent"
If used, this attribute can specify either the exact width of the header cell in pixels, or the width of the header cell as a percentage of the table being displayed. Only one header cell can set the width for an entire column, so it is good practice to specify all header cells in the same column as having the same width, if the attribute is set at all.
HEIGHT="value_or_percent"
If used, this attribute can specify either the exact height of the header cell in pixels, or the height of the header cell as a percentage of the browser display window. Only one header cell can set the height for an entire row.
NOTE : Netscape supports use of the WIDTH="value%"
and "pixel_value"
for this element (it only supports the HEIGHT="%value"
attribute for the main <TABLE>
element). Internet Explorer supports both percentage and pixel values for both the HEIGHT
and WIDTH
attributes.
For WIDTH="%value"
settings, the WIDTH="%value"
also needs to be set in the main <TABLE>
element and the headers/cells columns (affected by any header with a WIDTH="%value"
setting) will be scaled as a percentage of the table width (which would be scaled as a percentage of the browser window). Also, for WIDTH="value"
settings, the table will only be sized to the maximum extent of the browser window width (with headers/cells being scaled accordingly), unless the WIDTH="value"
setting is used in the main <TABLE>
element, set to the combined size of the headers/cells.
For HEIGHT="%value"
settings, the header (and any rows it is part of) will be rendered as the percentage of the browser window, regardless of any HEIGHT
settings in the main <TABLE>
. If only one header has a WIDTH
or HEIGHT
attribute set, then that setting is used for all the columns/rows of the table that the header is part of. If more than one header in a row or column have WIDTH
or HEIGHT
attributes set, then the largest setting of all the constituent headers/cells will be used for the entire row/column of the table. <TH>
WIDTH
s are also affected by any subsequent <TD>
WIDTH
settings, with the largest setting of the <TH>
and <TD>
elements being used for the entire column of the table.
NOWRAP
If this attribute appears in any table cell (<TH>
or <TD>
) it means the lines within this cell cannot be broken to fit the width of the cell. Be cautious in use of this attribute as it can result in excessively wide cells.
COLSPAN="value"
This attribute can appear in any table cell (<TH>
or <TD>
) and it specifies how many columns of the table this cell should span. The default COLSPAN
for any cell is 1.
ROWSPAN="value"
This attribute can appear in any table cell (<TH>
or <TD>
) and it specifies how many rows of the table this cell should span. The default ROWSPAN
for any cell is 1. A span that extends into rows that were never specified with a <TR>
will be truncated.
BGCOLOR="#rrggbb|colour name"
Internet Explorer and Netscape support use of this attribute (also supported in the <BODY>
element). It allows the background colour of the header cell to be specified, using either the specified colour names, or a rrggbb hex triplet.
BORDERCOLOR="#rrggbb|colour name"
Internet Explorer includes support for this attribute which sets the border colour of the header cell. Any of the pre-defined colour names can be used, as well as any colour defined by a rrggbb hex triplet. It is necessary for the BORDER
attribute to be present in the main <TABLE>
element for border colouring to work.
BORDERCOLORLIGHT="#rrggbb|colour name"
Internet Explorer allows use of the BORDERCOLORLIGHT
attribute to set independently, the lighter colour to be displayed on a 3-dimensional header cell border. It is the opposite of BORDERCOLORDARK
. Any of the pre-defined colour names can be used, as well as any colour defined by a rrggbb hex triplet. It is necessary for the BORDER
attribute to be present in the main <TABLE>
element for border colouring to work.
BORDERCOLORDARK="#rrggbb|colour name"
Internet Explorer allows use of the BORDERCOLORDARK
attribute to set independently, the darker colour to be displayed on a 3-dimensional header cell border. It is the opposite of BORDERCOLORLIGHT
. Any of the pre-defined colour names can be used, as well as any colour defined by a rrggbb hex triplet. It is necessary for the BORDER
attribute to be present in the main <TABLE>
element for border colouring to work.
NOTE : The BGCOLOR
, BORDERCOLOR
, BORDERCOLORLIGHT
and BORDERCOLORDARK
attributes can also be used in <TABLE>
, <TD>
and <TR>
elements, with the colour defined in the last element over-riding those defined before. E.g. if a <TD>
element contains a BORDERCOLOR
attribute setting, the setting specified will be used instead of any colour settings that may have been specified in the <TR>
element, which in turn over-rides any colour settings in the <TABLE>
element.
BACKGROUND="URL of image"
Internet Explorer and Netscape support the placing of images inside the <TH>
element. (Also in the <TABLE>
, and <TD>
elements) If used in the <TH>
element, the image in question will be tiled behind the particular data cell. Any of the supported graphic file formats can be used as a graphic behind a table.
TITLE="informational ToolTip"
The Internet Explorer 4.0 (and above) specific TITLE
attribute is used for informational purposes. If present, the value of the TITLE
attribute is presented as a ToolTip when the users mouse hovers over the <TH>
section.
LANG="language setting"
The LANG
attribute can be used to specify what language the <TH>
element is using. It accepts any valid ISO standard language abbreviation (for example "en"
for English, "de"
for German etc.) For more details, see the Document Localisation section for more details.
LANGUAGE="Scripting language"
The LANGUAGE
attribute can be used to expressly specify which scripting language Internet Explorer 4.0 uses to interpret any scripting information used in the <TH>
element. It can accept values of vbscript
, vbs
, javascript
or jscript
. The first two specify the scripting language as Visual Basic Script, the latter two specify it as using Javascript (the default scripting language used if no LANGUAGE
attribute is set.
CLASS="Style Sheet class name"
The CLASS
attribute is used to specify the <TH>
element as using a particular style sheet class. See the Style Sheets topic for details.
STYLE="In line style setting"
As well as using previously defined style sheet settings, the <TH>
element can have in-line stylings attached to it. See the Style Sheets topic for details.
ID="Unique element identifier"
The ID
attribute can be used to either reference a unique style sheet identifier, or to provide a unique name for the <TH>
element for scripting purposes. Any <TH>
element with an ID
attribute can be directly manipulated in script by referencing its ID
attribute, rather than working through the All collection to determine the element. See the Scripting introduction topic for more information.
Every <TH>
element in a document is an object that can be manipulated through scripting. Note that scripting of the <TH>
element/object is only supported by Internet Explorer 4.0 in its Dynamic HTML object model. Netscape does not support direct scripting of the <TH>
element at all.
<TH...>
Properties
Of the standard Dynamic HTML properties, the <TH...>
element/object supports the following: className, document, id, isTextEdit, lang, language, offsetHeight, offsetLeft, offsetParent, offsetTop, offsetWidth, parentElement, parentTextEdit, sourceIndex, style, tagName and title. Details of these can be found in the standard Dynamic HTML properties topics.
Additionally, the <TH>
element supports the following properties, all of which directly reflect attribute values: align, background, bgColor, borderColor, borderColorDark, borderColorLight, colSpan, noWrap, rowSpan and vAlign.
<TH...>
Methods
Of the standard Dynamic HTML methods, the <TH...>
element/object supports the following: click, contains, getAttribute, removeAttribute, scrollIntoView and setAttribute. Details of these can be found in the standard Dynamic HTML Methods topics.
<TH...>
Events
The <TH...>
element/object supports all of the standard Dynamic HTML events (i.e. onclick, ondblclick, ondragstart, onfilterchange, onhelp, onkeydown, onkeypress, onkeyup, onmousedown, onmousemove, onmouseout, onmouseover, onmouseup and onselectstart). Details of these can be found in the standard Dynamic HTML events topics.
© 1995-1998, Stephen Le Hunte