Knowledge baseExam Center
ENEnglish
Choose language13

CKTIS / HTML

td — table data cell

The td element represents a data cell in an HTML table. It is a child of tr; unlike th, it does not represent a row or column header.

Version: WHATWG HTML Living Standard; index snapshot date recorded separately

Syntax

<td>…</td>

The td element represents a table data cell and is placed directly inside tr. It accepts flow content, such as text, paragraphs, or links. Use th for headers rather than a visually emphasized td.

The colspan attribute specifies the number of columns occupied (1–1000), while rowspan specifies the number of rows (0–65534). The value rowspan="0" spans the remaining rows in the current row group. Cells must not overlap. Optional headers contains unique, space-separated id values of th elements in the same table.

The start tag is required. In text/html syntax, the end tag may be omitted immediately before td or th, or when there is no more content in the parent. The example writes it explicitly; its th headers describe the td containing 3.

Examples

<!doctype html>
<html lang="en">
<head>
  <meta charset="utf-8">
  <title>Table data cell</title>
</head>
<body>
  <table>
    <caption>Stock</caption>
    <thead>
      <tr><th scope="col">Item</th><th scope="col">Count</th></tr>
    </thead>
    <tbody>
      <tr><th scope="row">Pen</th><td>3</td></tr>
    </tbody>
  </table>
</body>
</html>

Result

Stock
Item  Count
Pen   3

The displayed code and declared result were verified in an isolated environment using the method recorded in the verification evidence for this exact version.

Sources