This stands for table data, and specifies a standard table data cell. Table data cells must only appear within table rows. Each row need not have the same number of cells specified as short rows will be padded with blank cells on the right. A cell can contain any of the HTML elements normally present in the body of an HTML document.
<TD ...> ... </TD>
can accept the following attributes.
ALIGN="left|center|right"
This attribute controls whether text inside the table cell(s) 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 cell(s) is aligned to the top, bottom, or vertically centred within the cell. It can also specify that all the cells in the row should be vertically aligned to the same baseline.
WIDTH="value_or_percent"
If used, this attribute can specify either the exact width of the data cell in pixels, or the width of the data cell as a percentage of the table being displayed. Only one data cell can set the width for an entire column, so it is good practice to specify all data 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 data cell in pixels, or the height of the data cell as a percentage of the browser display window. Only one data 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 cell/header columns (affected by any cell 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 cells/headers being scaled accordingly), unless the WIDTH="value"
setting is used in the main <TABLE>
element, set to the combined size of the cells/headers.
For HEIGHT="%value"
settings, the cell (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 cell has a WIDTH
or HEIGHT
attribute set, then that setting is used for all the columns/rows of the table that the cell is part of. If more than one cell in a row or column have WIDTH
or HEIGHT
attributes set, then the largest setting of all the constituent data cells will be used for the entire row/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 data 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 data 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 data 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 data 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>
, <TH>
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 <TD>
element. (Also in the <TABLE>
, and <TH>
elements) If used in the <TD>
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.