
HTML td Tag
The HTML <td>
tag is used to define a single cell within a table. It represents a data cell or a cell containing tabular data within a <tr>
(table row) element.
Here’s an example of how the <td>
tag can be used:
<table>
<tr>
<td>Data 1</td>
<td>Data 2</td>
</tr>
<tr>
<td>Data 3</td>
<td>Data 4</td>
</tr>
</table>
In the above example, the <td>
tag is used to define four data cells within a table. Each <td>
element represents a single cell, and the content inside the <td>
tags represents the data or information to be displayed within each cell.
By default, the content of <td>
elements is left-aligned within the cell. You can use CSS to apply different styles, such as text alignment, background color, borders, and padding, to customize the appearance of the cells.
The <td>
tags must always be placed within a <tr>
(table row) element, which represents a row within the table. You can have multiple rows with different numbers of cells within the same table.
Tables in HTML are structured using a combination of <table>
, <tr>
, and <td>
tags. The <table>
tag defines the table itself, the <tr>
tags define the rows, and the <td>
tags define the individual cells within each row.
By using the <td>
tag, you can create well-structured and organized tables to display tabular data on your web pages.