<tfoot>


HTML <tfoot> 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 <tfoot> tag.


Tag definition and usage instructions

<tfoot> tag is used to combine the footer content of HTML tables.

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

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<tfoot> tag must be used in the following situations: as a child element of the <table> element, after the <caption>, <colgroup> and <thead> elements, < before the tbody> and <tr> elements.


Tips and Notes

Notes: The <tfoot> 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 <tfoot> tag in HTML 4.01 are no longer supported.


Properties

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


Global attributes

<tfoot> tag supports global attributes of HTML.


Event attributes

<tfoot> tag supports HTML event attributes.