English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية
The HTML Table Body element ( <tbody> ) encapsulates a set of table rows ( <tr> elements ), indicating that they contain the main body ( <table> ) of the table.
Tables with <thead>, <caption>, <tfoot>, and <tbody> elements:
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title>Basic Tutorial(oldtoolbag.com)</title> <style type="text/css"> thead {color:#009900;} tbody {color:#0000cc;} tfoot {color:#ff0000;} </style> </head> <body> <table border="1"> <caption>Council budget 2020</caption> <thead> <tr> <th>Month</th> <th>Savings</th> </tr> </thead> <tfoot> <tr> <td>Sum</td> <td>$180</td> </tr> </tfoot> <tbody> <tr> <td>January</td> <td>$100</td> </tr> <tr> <td>February</td> <td>$80</td> </tr> </tbody> </table> <p><b>Tip:</b>thead, tbody, and tfoot elements are not by default affecting the table layout. However, you can use CSS to define styles for these elements and thus change the appearance of the table.</p> </body> </html>Test and see ‹/›
IEFirefoxOperaChromeSafari
All major browsers support the <tbody> tag.
The <tbody> tag is used to combine the main content of an HTML table.
The <tbody> element should be used with <thead> and <tfoot> These elements combined are used to define the various parts (body, header, footer) of a table.
By using these elements, browsers can support scrolling of the table body independently of the table header and footer. When printing a long table that spans multiple pages, the table header and footer can be printed on each page that contains table data.
The <tbody> tag must be used in the following scenarios: as a child element of the <table> element, appearing after the <caption>, <colgroup>, and <thead> elements.
Note:The <tbody> element must contain one or more <tr> tags within it.
Note:The <tbody> tag must appear after the <caption>, <colgroup>, and <thead> tags within a table, but before the <tfoot> tag.
Tip:<thead>, <tbody>, and <tfoot> elements do not affect the table layout by default. However, you can use CSS to define styles for these elements, thereby changing the appearance of the table.
In HTML 5 No longer supports HTML 4.01 Any attribute of the <tbody> tag.
Attribute | Value | Description |
---|---|---|
align | right left center justify char | HTML5 Not supported. Defines the alignment method for the content within the <tbody> element. |
char | character | HTML5 Not supported. Specifies which character to use for text alignment within the <tbody> element. |
charoff | number | HTML5 Not supported. Specifies the offset of the first alignment character within the <tbody> element. |
valign | top middle bottom baseline | HTML5 Not supported. Specifies the vertical alignment of the content within the <tbody> element. |
<tbody> tag supports HTML global attributes.
<tbody> tag supports HTML event attributes.