<td>
<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
<tfoot>
<tr>
<td>Footer content</td>
<td>Footer content</td>
</tr>
</tfoot>
<td>
element is specifically used for displaying table data.Example
A basic table with three columns, each containing a <td>
cell:
Emil | Tobias | Linus |
<table>
<tr>
<td>Emil</td>
<td>Tobias</td>
<td>Linus</td>
</tr>
</table>
Attributes
Attribute | Value | Description |
---|---|---|
colspan | number | Specifies the number of columns a cell spans |
headers | header_id | Associates the cell with one or more header IDs |
rowspan | number | Specifies 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.
<tr>
The HTML <tr> element represents a row in a table, consisting of one or more table cells (<td> or <th>), used to structure and present data in a tabular format.
<caption>
The HTML <caption> element serves as a title or description for a table, appearing as the first child of the <table> element to enhance clarity and accessibility.