The <td> tag is used to introduce a table detail element. For further discussion and examples see the table entry.
The <td> tag can take the following attributes.
The align attribute may be used to control the horizontal alignment of an element within a table cell.
Heading for column 1 | Heading for column 2 | Heading for column 3 |
---|---|---|
Item 1 | Item 2 | Item 3 |
The HTML for the above is
<table border=5> <tr><th>Heading for column 1<th>Heading for column 2<th>Heading for column 3 <tr><td align=left>Item 1<td align=center>Item 2<td align=right>Item 3 </table>
This can be used to highlight a particular cell as shown below
Heading for column 1 | Heading for column 2 | Heading for column 3 |
---|---|---|
Item 1 | Item 2 | Item 3 |
Note that the bgcolor attribute of the <td> tag is not defined in the HTML 3.2 standard however both Microsoft Internet Explorer and Netscape 3 support it, however Netscape 2 does not.
This can be used to control vertical alignment within a cell. The allowed values are top, middle and bottom.
The effect is illustrated by the following table
Heading for column 1 | Heading for column 2 | Heading for column 3 |
---|---|---|
![]() |
![]() | ![]() |
In the example above all cells also had the align attribute set to center.
Normally the text appearing in a table cell is wrapped at the discretion of the display software. Such wrapping can be prevented by using the nowrap attribute as shown below for column 2.
Column 1 | Column 2 | Column 3 |
---|---|---|
A quite long piece of text that is likely to be wrapped to fit into a cell | A really rather long piece of text that will not be wrapped | An item |
Here is the same table without the nowrap attribute
Column 1 | Column 2 | Column 3 |
---|---|---|
A quite long piece of text that is likely to be wrapped to fit into a cell | A really rather long piece of text that will not be wrapped | An item |
Both the above tables had the width attribute associated with the <table> tag.
This attribute is not in HTML 3.2. It tiles the background of a cell with an image. The value is the URL of the image file.
Here is an example.
Heading for column 1 | Heading for column 2 | Heading for column 3 |
---|---|---|
Item 1 | Item 2 | Item 3 |
Browsers
Only IE and NN4 honour the background attribute.
ARA does not honour the nowrap attribute.