<tbody>


HTML <tbody> Tag

Instance

<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8"> 
<title>php中文网(php.cn)</title> 
<style type="text/css">
thead {color:green;}
tbody {color:blue;}
tfoot {color:red;}
</style>
</head>
<body>

<table border="1">
  <thead>
    <tr>
      <th>Month</th>
      <th>Savings</th>
    </tr>
  </thead>
  <tfoot>
    <tr>
      <td>Sum</td>
      <td>0</td>
    </tr>
  </tfoot>
  <tbody>
    <tr>
      <td>January</td>
      <td>0</td>
    </tr>
    <tr>
      <td>February</td>
      <td></td>
    </tr>
  </tbody>
</table>

<p><b>提示:</b>  thead, tbody, 和 tfoot 元素默认不会影响表格的布局。不过,您可以使用 CSS 来为这些元素定义样式,从而改变表格的外观。</p>

</body>
</html>

Run Example»

Click the "Run Instance" button to view the online instance


Browser support

1000.png

All major browsers support the <tbody> tag.


Tag definition and usage instructions

<tbody> tag is used to combine the main content of the HTML table.

<tbody> elements should be related to <thead> and The <tfoot> elements are used in combination to specify the various parts of the table (body, header, footer).

By using these elements, the browser has the ability to support table body scrolling independent of table headers and table footers. When a long table containing multiple pages is printed, the table header and footer can be printed on each page containing the table data.

The<tbody> tag must be used as a child of the <table> element, after the <caption>, <colgroup>, and <thead> elements.


Tips and Notes

Note: The <tbody> element must contain one or more <tr> tags inside.

Tip: <thead>, <tbody> and <tfoot> elements do not affect the layout of the table by default. However, you can use CSS to define styles for these elements, thereby changing the appearance of the table.


Differences between HTML 4.01 and HTML5

In HTML 5, any attributes of the <tbody> tag in HTML 4.01 are no longer supported.


Properties

PropertiesValueDescription
alignright
left
center
Justify
char
HTML5 is not supported. Define the alignment of content in the <tbody> element.
charcharacterHTML5 Not supported. Specifies which character should be used for text alignment in the <tbody> element.
charoffnumberHTML5 Not supported. Specifies the offset of the first alignment character of the content in the <tbody> element.
valigntop
middle
bottom
Baseline
HTML5 is not supported. Specifies the vertical alignment of content in the <tbody> element.


Global attributes

The<tbody> tag supports global attributes of HTML.


Event attributes

<tbody> tag supports HTML event attributes.