<td>

The HTML <td> element defines a cell in a table, holding data within a row (<tr>) and allowing for structured data presentation.

<td> Tag

The <td> element is used within a table row <tr> to define a standard data cell. It can contain various types of content, including text, images, links, or even nested tables. By default, content inside a <td> cell is left-aligned. If a table requires header cells, the <th> element should be used instead.

Syntax

index.html
<tfoot>
  <tr>
    <td>Footer content</td>
    <td>Footer content</td>
  </tr>
</tfoot>
The <td> element is specifically used for displaying table data.

Example

A basic table with three columns, each containing a <td> cell:

Emil Tobias Linus
index.html
<table>
  <tr>
    <td>Emil</td>
    <td>Tobias</td>
    <td>Linus</td>
  </tr>
</table>
Table cells can hold various types of content, including text, images, links, and nested tables.

Attributes

AttributeValueDescription
colspannumberSpecifies the number of columns a cell spans
headersheader_idAssociates the cell with one or more header IDs
rowspannumberSpecifies the number of rows a cell spans

Global Attributes

The <td> element also supports all global attributes in HTML.

Conclusion

The <td> element plays a crucial role in organizing data within tables in HTML. It is used to define standard data cells in a table row and can contain various types of content, such as text, images, or links. With attributes like colspan and rowspan, it offers flexibility for structuring more complex tables.