td (HTML element)
| Depr. | Empty | Version |
|---|---|---|
| No | No | HTML 2 |
| IE5.5+ | FF1+ | SA1.3+ | OP9.2+ |
|---|---|---|---|
| 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.
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 | |||||||
|---|---|---|---|---|---|---|---|---|---|---|
| 5.5 | 6.0 | 7.0 | 1.0 | 1.5 | 2.0 | 1.3 | 2.0 | 3.0 | 9.2 | 9.5 |
| 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 thetdcontentsalign
aligns text in cells contained inside atdelementaxis
allows cell contents to be categorizedbgcolor
sets a background color for thetdchar
sets the character to which cell contents should aligncharoff
defines the number of characters by which cell contents will be offset from thecharcolspan
defines number of columns in table that a cell should spanheaders
indicates which table headers are related to this cellnowrap
instructs the browser not to wrap content inside the cellrowspan
defines the number of rows in table that cell should spanscope
specifies the direction of the table cells that the cell relates tovalign
aligns text vertically in table cellswidth
sets thetd’s width in pixels or as a percentage
User-contributed notes
- ID:
- #1
- Date:
- Fri, 28 Mar 2008 12:54:51 GMT
'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.'
The HEADERS attribute will occur in the TD, but the corresponding ID attributes would normally be found in TH elements.
Add a note
To post a note on this topic, please log in with your SitePoint username and password. If you don't have an account yet, you can create a new account for free.