HTML tbody Tag

HTML <tbody> Tag:  The HTML<tbody> tag specifies grouping the body content in an HTML table. This tag is use in HTML table with header and footer which is known as “thead” and “tfoot”. And it is child tag of table tag and parent tag of <tr> and <td> tags.

HTML<tbody>Tag

This HTML tbody tag supports both the global and the event attributes.

Syntax: <tbody> Text </tbody>

Attributes

Some attributes are supported by <tbody> tag in HTML4.1 but not supported in HTML5. The list of attributes are given below:

  • align: Set the alignment of the content.
  • valign: Set the vertical alignment of the content.
  • char: Set the alignment of content inside <thead> tag to a character.
  • charoff: It is used to set the characters the content inside the <thead> tag aligned from the character specified by the char attribute.

Browser compatibility

The HTML<tbody> tag is supported by different types of browsers.

  • Chrome
  • Firefox
  • Opera
  • Safari
  • Internet Explorer

Example:

<!DOCTYPE html>
<html>
<head>
<style>
thead {color:green;}
tbody {color:blue;}
tfoot {color:red;}

table, th, td {
  border: 1px solid black;
}
</style>
</head>

<body>

<table>
  <thead>
    <tr>
      <th>Programming Languages Text</th>
      <th>Price</th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <td>HTML</td>
      <td>$100</td>
    </tr>
    <tr>
      <td>C</td>
      <td>$80</td>
    </tr>
  </tbody>
  <tfoot>
    <tr>
      <td>C++</td>
      <td>$180</td>
    </tr>
  </tfoot>
</table>
</body>
</html>

Output:

html tbody tag

 

 

 

 

Attributes that are supported by the <tbody> tag

Attribute Value Description
align left
center
right
justify
char
Aligns the content inside the element
char character Aligns the content inside the

element to a character

charoff number Sets the number of characters the content inside the

element will be aligned from the character specified by the char attribute

valign top
middle
bottom
baseline
Vertical aligns the content inside the element

Global and event attributes

This tag supports both the global and the event attributes.