Description

The HTML element <tbody> is used to define a table's body.

  • It groups a set of rows that defines the main body that contains table data.
  • It must be defined as a child of the <table> element after the <caption>, <colgroup>, and <thead> elements in case they are defined.
  • It must contain at least one row defined using the <tr> element.

The below table summarizes its usage.

Usage Details
Placement It is a child of <table> element.
Contents It can contain one or more <tr> elements.
Tags Both opening and closing tags are required.
Versions HTML 4, 4.01, 5

Syntax

Here is the basic syntax of the <tbody> element.

<tbody>...</tbody>

Examples

Run this on IDE

<!DOCTYPE html>
<html lang="en">
<head>
    <title>Example - HTML Element table</title>
</head>
<body>
    <table>
        <caption>Products List</caption>
        <thead>
            <tr>
                <th>Product</th>
                <th>Sales</th>
            </tr>
        </thead>
        <tbody>
            <tr>
                <td>Bread</td>
                <td>10000</td>
            </tr>
            <tr>
                <td>Butter</td>
                <td>3000</td>
            </tr>
        </tbody>
    </table>
</body>
</html>

Attributes

The following table shows the list of supported and unsupported attributes for the <tbody> element.

Attribute Type Details
Element-Specific Attributes The tag <tbody> has some element-specific attributes listed in the below table.
Global Attributes Like all other HTML tags, the tag <tbody> supports the HTML Global Attributes.
Event Attributes The tag <tbody> also supports the HTML Event Attributes.

Here is a list of attributes that are specific to the <tbody> element.

Attribute Value Required Description
align left, right, center, justify, char No Obsolete
Specifies the alignment of cell contents inside the tbody element.
char character No Obsolete
Sets the character to which cell contents of the related tbody element should align.
charoff number No Obsolete
Defines the number of characters by which cell contents of the related tbody element will be offset from the alignment characters specified by the char attribute.
valign top, middle, bottom, baseline No Obsolete
Specifies the vertical alignment of content within each cell of the related tbody element.

Browser Compatibility

The tag <tbody> is supported in all modern browsers.

  • Google Chrome 1+
  • Internet Explorer or Edge 4+
  • Firefox 1+
  • Apple Safari 1+
  • Opera 5+

Related Links