Tables

HTML <td> element

Represents a table data cell. colspan and rowspan can span multiple columns or rows; maintain understandable header relationships. Keep each data cell in a row and use suitable th headers. Spanning cells changes the logical grid; check that assistive technologies can still identify the relevant headers. It accepts global HTML attributes; individual global features may be inapplicable or restricted.

Formal Syntax & Structure

html syntaxhtml
<td>Data</td>

Parameters & Attributes

NameTypeDescription
colspanpositive integerMakes a table cell occupy multiple columns. Default is 1; the conforming range is 1 to 1000. Maintain a coherent table grid.
rowspannon-negative integerMakes a table cell occupy multiple rows. Default is 1; zero extends the cell to the remaining rows in its row group. Avoid overlaps in the resulting grid.
headersspace-separated header IDsAssociates a table cell with th elements in the same table using explicit IDs. Useful for complex header relationships that cannot be expressed clearly using scope alone.

Return Value

HTMLTableCellElement

Content model: Flow content.

Working Example

Example Snippethtml
<!doctype html><html lang="en">  <head>    <meta charset="utf-8">    <title>HTML example</title>  </head>  <body>    <table>      <tr>        <th scope="col">Item</th>        <th scope="col">Count</th>      </tr>      <tr>        <td>Books</td>        <td>2</td>      </tr>    </table>  </body></html>
HTML Reference