| Depr. | Empty | Version |
|---|---|---|
| No | No | HTML 2 |
| IE5.5+ | FF1+ | SA1.3+ | OP9.2+ | CH2+ |
|---|---|---|---|---|
| Full | Full | Full | Full | Full |
Syntax
Description
You can use two kinds of cells in a table: the th element is reserved for cells that contain
header information, but the td can be used for any kind
of data. Aside from that difference of usage and meaning (and the default
presentational differences—th text is bold and centered
while td text is non-bold and left-aligned), in almost
every other way, the td element behaves, and has the
same attributes, as the th element.
The axis and
scope attributes can also be used
in td elements, and this is a perfectly valid use of
HTML, but you’re advised to reserve your usage of these attributes to
table headers only. However, the headers and id
are almost certainly going to be used in td elements
for the purpose of creating relationships between the
td content and the header cells (with the
th header cell identified using the
id attribute and the td
associated with it referring to that header with a matching headers attribute).
Finally, this element uses the colspan and
rowspan attributes when the content of the cell
needs to run across multiple columns or rows.
Example
These
td elements are used in a two-column
row:
<tr> <td>Smart</td> <td>From 2%</td> </tr>
Use This For …
The
td is used for content in a table that represents
standard data (that’s to say, it’s not a header cell, and most likely
falls under a column or row header).
Compatibility
| Internet Explorer | Firefox | Safari | Opera | Chrome | ||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 5.5 | 6.0 | 7.0 | 8.0 | 1.0 | 1.5 | 2.0 | 3.0 | 3.5 | 1.3 | 2.0 | 3.1 | 4.0 | 9.2 | 9.5 | 10.0 | 2.0 |
| Full | Full | Full | Full | Full | Full | Full | Full | Full | Full | Full | Full | Full | Full | Full | Full | Full |
It causes no compatibility issues, and has excellent support across all tested browsers.
In this Section
- abbr
provides an abbreviated version of the td contents - align
aligns text in cells contained inside a td element - axis
allows cell contents to be categorized - bgcolor
sets a background color for the td - char
sets the character to which cell contents should align - charoff
defines the number of characters by which cell contents will be offset from the char - colspan
defines number of columns in table that a cell should span - headers
indicates which table headers are related to this cell - nowrap
instructs the browser not to wrap content inside the cell - rowspan
defines the number of rows in table that cell should span - scope
specifies the direction of the table cells that the cell relates to - valign
aligns text vertically in table cells - width
sets the td’s width in pixels or as a percentage