<td> elementThe <td> element defines a standard data cell in a table — one value belonging to a particular row and column, as opposed to a <th>, which labels a row or column rather than holding one of its values.
A <td> must appear inside a <tr>. It can contain ordinary flow content — text, links, images, even another table — not just plain text.
The colspan attribute specifies how many columns a cell occupies, from 1 to 1000. The rowspan attribute specifies how many rows it occupies, from 1 to 65534; the special value 0 extends it through the remaining rows of its row group. Both default to 1. Spanning cells must not overlap other cells or cross row-group boundaries.
An empty <td> is valid and renders as a blank cell — useful for genuinely empty data, but worth double-checking against colspan/rowspan on neighbouring rows before assuming a table is broken just because a cell looks blank.
The headers attribute lists the IDs of associated <th> cells in the same table, separated by spaces. For example, headers="ada html-score" explicitly associates a score with those two headings. This is useful for complex tables; simple row and column headings can usually be expressed with scope on their header cells.
The example below uses colspan="2" for a result that applies to both subjects. That row needs just one data cell after its name heading because the data cell occupies both score columns.
Attributes: colspan, rowspan, headers, GLOBALS.
Typical layout: <table> <caption>Workshop scores</caption> <thead> <tr> <th scope="col">Name</th> <th scope="col">HTML</th> <th scope="col">CSS</th> </tr> </thead> <tbody> <tr> <th scope="row">Ada</th> <td colspan="2">Awaiting results</td> </tr> </tbody> </table>
Visual representation:
| Name | HTML | CSS |
|---|---|---|
| Ada | Awaiting results | |