Definition
The <tbody>
tag encloses a block of table rows (<tr>
elements), which consists of the body of the table.
Example
<table>
<caption>This is the table's caption</caption>
<thead>
<tr>
<th colspan="2">The table header with one column</th>
</tr>
</thead>
<tbody>
<tr>
<td>The table body</td>
<td>with two columns</td>
</tr>
</tbody>
</table>
Usage
- An opening tag can be omitted if the first child is a
<tr>
element, and if that element is not immediately preceded by a<tbody>
,<thead>
, or<tfoot>
element whose closing tag has been omitted. - A closing tag can be omitted if the
<tbody>
element is immediately followed by a<tbody>
or<tfoot>
element, or if there is no more content in the parent element. - The
<tbody>
element should be a child of a<table>
element, after any<caption>
,<colgroup>
, or<thead>
elements, but only if there are no ¬<tr>
elements that are children of the<table>
element. - The
<tbody>
element may contain zero or more<tr>
elements. - The
<tbody>
is used together with the<thead>
and<tfoot>
to specify each part of the footer; head, body, and footer. Browsers can use these elements to enable scrolling of the table body independantly of the footer. Furthermore, when printing tables that span multiple pages, the header and footer will be printed on each page. - You can use more than one
<tbody>
per table in order to divide the table into sections. For example:<table> <caption>Car Prices</caption> <thead> <tr> <th>Model</th> <th>Price</th> </tr> </thead> <tbody> <tr> <th colspan="2">BMW</th> </tr> <tr> <td>320d</td> <td>$30,000</td> </tr> <tr> <td>530d</td> <td>$50,000</td> </tr> </tbody> <tbody> <tr> <th colspan="2">Ford</th> </tr> <tr> <td>Fiesta</td> <td>$15,000</td> </tr> <tr> <td>Mondeo</td> <td>$32,000</td> </tr> </tbody> </table>
Attributes
The <tbody>
element only supports the Global Attributes.
Specification
Browser Support
Desktop
Chrome | Edge | Firefox | IE | Opera | Safari |
---|---|---|---|---|---|
Yes | Yes | Yes | Yes | Yes | Yes |
Mobile
Android Webview | Chrome Android | Firefox Android | Opera Android | iOS Safari | Samsung Internet |
---|---|---|---|---|---|
Yes | Yes | Yes | Yes | Yes | Yes |