Summary -

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

Table row in HTML document. The <tr> tag used to specify the row in an HTML <table>. Table row contains one or more data cells (td) and/or header cells (th).

<tr> elements are child of <table>, <tbody>, <thead> or <tfoot> elements. <tr> element can be specified after any <caption>, <colgroup>, and <thead> elements.

The tag can be specified like <tr></tr> with the table cell elements in between the opening and closing tags.

Syntax -

<thead>.... </thead>

Optional Attributes -

AttributeDescriptionValues
AlignSpecifies the tr content alignment.Not supported in HTML5centercharjustifyleftright
BgcolorSpecifies the tr background color.Not supported in HTML5Rgb(x,x,x)#xxxxxxColorname
CharSpecifies the tr content to char.Not supported in HTML5Character
ValignSpecifies the tr content should be vertically aligned.Not supported in HTML5TopMiddleBottombaseline

Example -

<!DOCTYPE html>
<html>
	<head>
		<title> Table 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