HTML Encyclopaedia

The td tag

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.

  1. align

    The align attribute may be used to control the horizontal alignment of an element within a table cell.

    Heading for column 1Heading for column 2Heading for column 3
    Item 1Item 2Item 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>
    

  2. bgcolor

    This can be used to highlight a particular cell as shown below

    Heading for column 1Heading for column 2Heading for column 3
    Item 1Item 2Item 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.

  3. valign

    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 1Heading for column 2Heading for column 3

    In the example above all cells also had the align attribute set to center.

  4. nowrap

    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 1Column 2Column 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 wrappedAn item

    Here is the same table without the nowrap attribute

    Column 1Column 2Column 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 wrappedAn item

    Both the above tables had the width attribute associated with the <table> tag.

  5. background

    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 1Heading for column 2Heading for column 3
    Item 1Item 2Item 3

Browsers
Only IE and NN4 honour the background attribute. ARA does not honour the nowrap attribute.


See also <tr>, <th>, <table>, <caption>, and the general notes on tables.