HTML td tag
Table data cell in table HTML documents. The <td> tag represents a cell in an HTML <table>. <td> elements are child elements of <tr>(table row) element.
It also defines the table data cell in HTML. The data is left-aligned in table cell by default.
The tag can be specified like <td></td> with the data inbetween the opening and closing tags. <td> tag is nested tag.
Syntax -
<td>.... </td>
| Attribute | Description | Values |
|---|---|---|
| Abbr | Specifies the cell content abbreviated version.Not supported in HTML5 | Text |
| Align | Specifies the cell content alignment.Not supported in HTML5 | CenterCharJustifyLeftRight |
| Bgcolor | Specifies the cell background color.Not supported in HTML5 | Rgb(x,x,x),#xxxxxx,Colorname |
| Char | Aligns the cell content to char.Not supported in HTML5 | Character |
| Colspan | Specifies the number of columns that cell should span. | Number.Default value 1. |
| Headers | Specifies the how many header cells the cell related to | Header_cell_id |
| Height | Specifies the cell height.Not supported in HTML5 | Number/pixels |
| Nowrap | Specifies the cell content should not wrap.Not supported in HTML5 | Number |
| Rowspan | Specifies the number of rows that cell should span. | Number |
| Scope | Specifies the how the cell associates with header and data cells.Not supported in HTML5 | ColColgroupRowrowgroup |
| Valign | Specifies the cell content vertical alignment.Not supported in HTML5 | TopMiddleBottombaseline |
| Width | Specifies the cell width.Not supported in HTML5 | Number/pixels |
Example -
<!DOCTYPE html>
<html>
<head>
<title> Tbody element example.. </title>
</head>
<body>
<table>
<thead>
<tr>
<th>Employee</th>
<th>Salary</th>
</tr>
</thead>
<tfoot>
<tr>
<td>Total</td>
<td>$10000</td>
</tr>
</tfoot>
<tbody>
<tr>
<td>Pawan</td>
<td>$5000</td>
</tr>
<tr>
<td>Srinivas</td>
<td>$5000</td>
</tr>
</tbody>
</table>
</body>
</html>
Output -
| Employee | Salary |
|---|---|
| Total | $10000 |
| Pawan | $5000 |
| Srinivas | $5000 |