Syntax | <TD>...</TD> |
---|---|
Attribute Specifications |
|
Contents | Inline elements, block-level elements |
Contained in | TR |
The TD element defines a data cell in a table. TD elements are contained within a TR element (a table row), which may also contain TH elements for header cells. When a cell's contents act as both header information and table data, TD should be used.
The ROWSPAN and COLSPAN attributes of TD specify the number of rows and the number of columns, respectively, that are spanned by the cell. The default value is 1. The special value 0 indicates that the cell spans all rows or columns to the end of the row group (THEAD, TBODY, TFOOT) or column group. The value 0 is ignored by most browsers, so authors may wish to calculate the exact number of rows or columns spanned and use that value.
The HEADERS attribute specifies the header cells that apply to the TD. The value is a space-separated list of the header cells' ID attribute values. The HEADERS attribute allows non-visual browsers to render the header information for a given cell.
The ABBR, SCOPE, and AXIS attributes should only be used if the cell provides header information. Like HEADERS, these attributes are new in HTML 4.0 and not well supported, though they should be particularly helpful to non-visual browsers in the future.
ABBR gives an abbreviated version of the cell's content. This allows visual browsers to use the short form if space is limited, and non-visual browsers can give a cell's header information in an abbreviated form before rendering each cell.
The SCOPE attribute specifies the cells for which the TD element provides header information. SCOPE is a simpler alternative to using HEADERS if the arrangement of header cells is not complex. Possible values are as follows:
The AXIS attribute provides a method of categorizing cells. The attribute's value is a comma-separated list of category names. See the HTML 4.01 Specification's section on categorizing cells for an application of AXIS.
In addition to the attributes common to most elements, TD takes a number of presentational attributes. Style sheets provide a more flexible way to suggest a presentation for table cells, but TD's presentational attributes are more widely supported by current browsers.
The ALIGN attribute specifies the horizontal alignment for the cell. Possible values are left, center, right, justify, and char. ALIGN=char, poorly supported among browsers, aligns a cell's contents on the character given in the CHAR attribute. The default value for the CHAR attribute is the decimal point of the current language--a period in English. The CHAROFF attribute specifies the offset to the first occurrence of the alignment character. The attribute's value is a number in pixels or a percentage of the cell's width; CHAROFF="50%" centers the alignment character horizontally in a cell.
The VALIGN attribute specifies the vertical position of a cell's contents. Possible values are:
The WIDTH, HEIGHT, NOWRAP, and BGCOLOR attributes are all deprecated in favor of style sheets. WIDTH and HEIGHT suggest the cell's width and height in pixels or as a percentage of the available space. The boolean NOWRAP attribute tells visual browsers to disable word wrap for the cell, which can result in unnecessary horizontal scrolling depending on the user's window width and font size.
The BGCOLOR attribute suggests a background color for the cell. The combination of this attribute with <FONT COLOR=...> can leave invisible or unreadable text on Netscape 2.x, which does not support BGCOLOR on table elements. BGCOLOR is dangerous even on supporting browsers, since some fail to override it when overriding other author-specified colors. Style sheets provide a safer, more flexible method of specifying a table's background color.