HTML td
Created By: chatGPT
In HTML, a table data cell is defined using the
<td>
tag. This tag is used within a <tr>
(table row) to specify a cell that contains data. Cells can contain text, images, links, and more, making them versatile for displaying information in tabular format.<table>
<tr>
<td>Row 1, Cell 1</td>
<td>Row 1, Cell 2</td>
</tr>
<tr>
<td>Row 2, Cell 1</td>
<td>Row 2, Cell 2</td>
</tr>
</table>
You can also use various attributes with the
<td>
tag to enhance your table. For example, the colspan and rowspan attributes allow a cell to span multiple columns or rows, respectively.<table>
<tr>
<td colspan="2">This cell spans 2 columns</td>
</tr>
<tr>
<td>Row 2, Cell 1</td>
<td>Row 2, Cell 2</td>
</tr>
</table>
To style your
<td>
elements, you can use CSS. This can include changing the background color, text alignment, and padding to improve the readability of the data displayed.<style>
td {
padding: 10px;
text-align: center;
border: 1px solid #000;
background-color: #f3f3f3;
}
</style>
<table>
<tr>
<td>Styled Cell 1</td>
<td>Styled Cell 2</td>
</tr>
</table>