HTML <tbody> Tag

The <tbody> tag defines the body content (a set of rows) of an HTML table creating a separate semantic block in it. The <body> tag is used along with the <thead> and the <tfoot> tags, which specify header and footer of the table respectively.

The <tbody> tag must be used as a child of the <table> element, after the <caption>, <colgroup> (if any) and the <thead> elements. (You can use several <tbody> tags inside <table>). The <tfoot> tag must be placed before <tbody>, so that the browser can render the table footer correctly.

The <thead>, <tbody>, and <tfoot> elements do not affect the layout of the table by default. Use CSS properties to customize the look of the table.

Syntax

<table>
  <thead> ... </thead>
  <tfoot>
    <tr>
      <td> ... </td>
    </tr>
  </tfoot>
  <tbody> ... </tbody>
</table>

Example

<!DOCTYPE html>
<html>
  <head>
    <title>Title of the document</title>
    <style>
      th, td {
        padding: 10px;
        border: 1px solid #666;
      }
    </style>
  </head>
  <body>
    <table style="width:80%; margin:30px auto; border-collapse:collapse;">
      <thead style="background-color:#1c87c9; color:#fff;">
        <tr>
          <th>Month</th>
          <th>Savings</th>
        </tr>
      </thead>
      <tfoot style="background-color:grey;">
        <!-- <tfoot> is placed after <thead>, but is shown on the bottom of the table. -->
        <tr>
          <td>Total</td>
          <td>1500</td>
        </tr>
      </tfoot>
      <tbody style="background-color:lightgrey;">
        <tr>
          <td>January</td>
          <td>500</td>
        </tr>
        <tr>
          <td>February</td>
          <td>1000</td>
        </tr>
      </tbody>
    </table>
  </body>
</html>

Result

Attributes

Attribute Values Description
align right
left
center
justify
char
Specifies the alignment of the content inside <tbody> element.
Not supported in HTML5
bgcolor bgcolor Sets the background color of the rows inside <tbody> element.
Not supported in HTML5.
char character Specifies the alignment of the content inside the <tbody> element to a character. Is used only when the attribute align = "char".
Not supported in HTML5.
charoff number Specifies the number of characters the content inside the <tbody> element will be aligned from the character specified by the char attribute. Is used only when the attribute align = "char".
Not supported in HTML5.
valign top
bottom
middle
baseline
Specifies a vertical alignment of the content inside the <tbody> element.
Not supported in HTML5.

The <tbody> tag also supports the Global Attributes and the Event Attributes.

Browser support