Tbody HTML

HTML <tbody> Tag

To group the rows of a table, the HTML <tbody> tag is used. It thus suggests that the content within it is the body part of the table. It is used as a child of the <table> element along with the <thead> and <tfoot> tags. The HTML <tbody> tag, however, does not affect the layout of the table but is used for providing semantic information. One or more <tr> elements must be placed within a <tbody> tag.

Syntax:

<tbody>content</tbody>

Example:

<!DOCTYPE html>
<html>
<head>
<style>
thead {background-color:lightgray;}
tbody {background-color:pink;}
tfoot {background-color:wheat;}
table, th, td {
  border: 2px solid brown;
}
</style>
</head>
<body>
<table>
  <thead>
    <tr>
    <th>NAME</th>
    <th>AGE</th> 
    </tr>
  </thead>
  <tbody>
    <tr>
    <td>Tom</td>
    <td>20</td>
    </tr>
    <tr>
    <td>Jerry</td>
    <td>10</td>
    </tr>
  </tbody>
  <tfoot>
    <tr>
      <td>Average</td>
      <td>15</td>
    </tr>
  </tfoot>
</table>
</body>
</html>

Explanation:

In the above example, we have displayed the use of the HTML <tbody> tag along with the other HTML table tags.

Tag specific Attributes:

Attribute Value Uses HTML 5
align right

left

center

justify

char

Used to define the content alignment inside the <tbody> element. Not Supported in HTML5.
char character Used to define the content alignment of the <tbody> tag to the character. Not Supported in HTML5.
charoff Number Used to define the number of characters the <tbody> content will be aligned from the character specified by the char attribute. Not Supported in HTML5.
valign top

middle

bottom

baseline

Used to define the vertical content alignment inside the <tbody> element. Not Supported in HTML5.

Global Attributes:

The HTML Global attributes are supported by the HTML <tbody> tag.

Event Attributes:

The HTML Event attributes are supported by the HTML <tbody> tag.

Supporting Browser:

Chrome, IE, Firefox, Opera, and Safari.