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 supports 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.