Summary -
In this topic, we described about the <tbody> tag along with detailed example.
Group a block of table rows in HTML document. The <tbody> tag allows grouping a block of table rows in an <table>. It represents the row blocks that consist of table body data.
The tag can be specified like <tbody></tbody> with the table body elements in between the opening and closing tags. The <tbody> element mostly used in conjunction with <thead> and <tfoot> tags to enable table scrolling.
<tbody> tag is optional tag. If <tbody> tag is used, then it must be the child of <table> element after <caption>/<colgroup>/thread> tags. The <tbody> element must have one or more <tr> tags inside.
Syntax -
<tbody>.... </tbody>
Optional Attributes -
Attribute | Description | Values |
---|---|---|
Align | Specifies the content alignment inside the <tbody> element.Not supported in HTML5 | LeftrightCenterJustify |
Char | Content aligns to character inside <tbody> tag | Character |
Valign | Specifies the content alignment to vertical inside <tbody> tag. | TopMiddleBottombaseline |
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 |