Summary -

In this topic, we described about the <td> tag along with detailed example.

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>

Optional Attributes -

AttributeDescriptionValues
AbbrSpecifies the cell content abbreviated version.Not supported in HTML5Text
AlignSpecifies the cell content alignment.Not supported in HTML5CenterCharJustifyLeftRight
BgcolorSpecifies the cell background color.Not supported in HTML5Rgb(x,x,x),#xxxxxx,Colorname
CharAligns the cell content to char.Not supported in HTML5Character
ColspanSpecifies the number of columns that cell should span. Number.Default value 1.
HeadersSpecifies the how many header cells the cell related toHeader_cell_id
HeightSpecifies the cell height.Not supported in HTML5Number/pixels
NowrapSpecifies the cell content should not wrap.Not supported in HTML5Number
RowspanSpecifies the number of rows that cell should span.Number
ScopeSpecifies the how the cell associates with header and data cells.Not supported in HTML5ColColgroupRowrowgroup
ValignSpecifies the cell content vertical alignment.Not supported in HTML5TopMiddleBottombaseline
WidthSpecifies the cell width.Not supported in HTML5Number/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