Description

The HTML element <td> is used to define a table data or a table cell, that contains data.

A table cell can contain two types of information.

  • Element <th> for header information, which is rendered and displayed with bold font by the browsers.
  • Element <td> for data, which is rendered and displayed as a regular text.
  • Elements <th> and <td> are rendered and displayed differently by the browsers as mentioned above, without any additional CSS.

The below table summarizes its usage.

Usage Details
Placement It is a child of <tr> element.
Contents It can contain Block elements, Inline elements, and text.
Tags Both opening and closing tags are required.
Versions HTML 3.2, 4, 4.01, 5

Syntax

Here is the basic syntax of the <td> element.

<td>...</td>

Examples

Run this on IDE

<!DOCTYPE html>
<html lang="en">
<head>
    <title>Example - HTML Element td</title>
</head>
<body>
    <table>
        <caption>Products List</caption>
        <thead>
            <tr>
                <th>Product</th>
                <th>Sales</th>
            </tr>
        </thead>
        <tbody>
            <tr>
                <td>Bread</td>
                <td>10000</td>
            </tr>
            <tr>
                <td>Butter</td>
                <td>3000</td>
            </tr>
        </tbody>
    </table>
</body>
</html>

Attributes

The following table shows the list of supported and unsupported attributes for the <td> element.

Attribute Type Details
Element-Specific Attributes The tag <td> has some element-specific attributes listed in the below table.
Global Attributes Like all other HTML tags, the tag <td> supports the HTML Global Attributes.
Event Attributes The tag <td> also supports the HTML Event Attributes.

Here is a list of attributes that are specific to the <td> element.

Attribute Value Required Description
abbr text No Obsolete
Provides a short abbreviated description of the cell's content.
align left, right, center, justify, char No Obsolete
Specifies the alignment of cell content.
axis text No Obsolete
Categorizes table cells.
bgcolor color No Obsolete
Sets the background color of a table cell.
char character No Obsolete
Sets the character to which cell contents should align.
charoff number No Obsolete
Defines the number of characters by which cell contents will be offset from the alignment characters specified by the char attribute.
colspan number No Specifies the number of columns spanned by the current cell.
headers header-id No Specifies one or more header cells a cell is related to.
height length No Obsolete
Sets the height of the table cell.
nowrap nowrap No Obsolete
This boolean attribute tells the browser to disable automatic text wrapping for this cell.
rowspan number No Specifies the number of rows spanned by the current cell.
scope col, colgroup, row, rowgroup No Obsolete
Specifies a way to associate header cells and data cells in a table.
valign top, middle, bottom, baseline No Obsolete
Specifies the vertical alignment of content within each cell of the related tbody element.
width length No Obsolete
Sets the width of a table cell.

Browser Compatibility

The tag <td> is supported in all modern browsers.

  • Google Chrome 1+
  • Internet Explorer or Edge 2+
  • Firefox 1+
  • Apple Safari 1+
  • Opera 4+

Related Links