The <td>
HTML tag defines a cell of a table. It is used to display data within a table row (<tr>
). The <td>
tag is usually used in combination with the <table>
, <th>
, and <tr>
tags.
Code Example:
<table>
<tr>
<th>Name</th>
<th>Email</th>
</tr>
<tr>
<td>John Doe</td>
<td>[email protected]</td>
</tr>
<tr>
<td>Jane Smith</td>
<td>[email protected]</td>
</tr>
</table>
Table Cells <td>
Attributes:
- colspan: Specifies the number of columns a cell should span across.
- rowspan: Specifies the number of rows a cell should span downward.
- headers: Links the cell to one or more header cells in the same row.
- scope: Indicates the relationship between the table headers (
<th>
) and the table data (<td>
). - abbr: Provides a shortened version of the content for use in limited spaces, such as tooltips or alternate versions of the page.
- axis: Specifies an axis to which the cell belongs.
- id: Specifies a unique id for the element.
- class: Specifies one or more class names for the element.
- style: Specifies an inline style for the element.
- title: Specifies extra information about the element, such as tooltips.
- lang: Specifies the language of the content in the cell.
- dir: Specifies the text direction of the content in the cell.
Conclusion:
The <td>
HTML tag is an essential component of a table structure in web development. It helps to organize and display data meaningfully in a way that is easy for users to read and understand. The various attributes associated with the <td> tag provide flexibility and customization options, allowing you to create tables that suit your specific needs.