Last Updated : 12 Jul, 2025
The <td> tag defines a standard data cell in an HTML table, used to contain content such as text, images, or numbers within a table row (<tr>).
HTML
<html>
<body>
<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>
</body>
</html>
Cells
Description
It contains header information(tags used for this is <th>). The text in <th> elements is bold and centered for heading by default.
Standard cells
It contains data(tags used for this is <td>). The text in <td> elements are regular and left-aligned for data by default.
Attributes ValuesAttributes Values
Description
It specifies the number of rows covered by the cell.
It determines the number of columns covered by the cell.
It identifies the data cell uniquely in the table.
It specifies the CSS class to style the cell.
It gives the visual appearance of the cell through CSS properties.
There are many attributes supported by HTML4.1 but removed from HTML5 are listed below:Removed from HTML 5
Description
This attribute is used as an abbreviated version of the text content in a header cell.
It sets the alignment the text content within the table.
It categorizes header cells in the table.
It sets the background color of a header cell.
Aligns the content in a header cell to a character.
It is used to sets the number of characters that will be aligned from the character specified by the char attribute. The value of these attributes are in numeric form.
Number of columns a header cell should span.
Specifies multiple header cells a cell is related to.
It sets the height of a header cell in the table.
It specifies that the content inside a header cell should not wrap.
It is used to specify the score of header content.
sorted
It is used to sort the direction of a column.
It is used to set the vertical alignment of text content.
It is used to set the width of a header cell.
More Example of HTML td tag
Using rowspan to Merge Cells Vertically html
<html>
<body>
<table border="1">
<tr>
<th>Item</th>
<th>Description</th>
</tr>
<tr>
<td rowspan="2">Laptop</td>
<td>Brand: XYZ</td>
</tr>
<tr>
<td>Price: $999</td>
</tr>
</table>
</body>
</html>
In this Example:
<html>
<head>
<style>
table {
border-collapse: collapse;
}
td {
border: 1px solid black;
padding: 8px;
}
td:nth-child(even) {
background-color: #f9f9f9;
}
</style>
</head>
<body>
<table>
<tr>
<td>Alice</td>
<td>30</td>
</tr>
<tr>
<td>Bob</td>
<td>25</td>
</tr>
</table>
</body>
</html>
In this Example:
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4