<tfoot>

HTML <tfoot> Tag

The <tfoot> tag defines the footer of an HTML table. It is used together with the <thead> and <tbody> elements, which define the header and the body of the table correspondingly.

The <tfoot> tag must be declared inside the <table> element, after the <caption>, <colgroup> (if any) and the <thead> elements. Note, that <tfoot> must be placed before <tbody>, so that the browser can render the table footer correctly.

The <tfoot> tag must contain at least one <tr> tag.

The <thead>, <tbody>, and <tfoot> elements do not affect the layout of the table by default. Use CSS properties to customize the look of the table.

Syntax

Syntax (语法)

The <tfoot> tag comes in pairs. The content is written between the opening (<tfoot>) and closing (</tfoot>) tags.

<table>
 <thead> ... </thead>
 <tfoot>
   <tr>
     <td> ... </td>
   </tr>
 </tfoot>
 <tbody> ... </tbody>
</table>

Example of the HTML <tfoot> tag:

<!DOCTYPE html>
<html>
 <head>
   <title>The title of the document.</title>
 </head>
 <body>
   <table summary="Goalscorers" width="400" border="1">
     <caption>
       FIFA World Cup 2018 Top Goalscorers
(2018年FIFA世界杯最佳射手)
       <hr>
     </caption>
     <thead>
       <tr>
         <th>Name</th>
         <th>Country</th>
         <th>Goal</th>
       </tr>
     </thead>
     <tfoot>
       <tr>
         <th colspan="3">Harry Kane - the best player!</th>
       </tr>
     </tfoot>
     <tbody>
       <tr>
         <td>Harry Kane</td>
         <td>England</td>
         <td>6</td>
       </tr>
       <tr>
         <td>Christiano Ronaldo</td>
         <td>Portugal</td>
         <td>4</td>
       </tr>
       <tr>
         <td>Neymar</td>
         <td>Brazil</td>
         <td>2</td>
       </tr>
     </tbody>
   </table>
 </body>
</html>

Result

The <tfoot> and other tags for summarizing table contents

The <tfoot> and other tags for summarizing table contents

The <tfoot> element provides summary information about the content of an HTML table. It comes either before or after the tbody element of the table, but is always rendered at the bottom of the table.

Use the <tfoot>, <tbody>, and <thead> elements to arrange tables containing complex data sets. Due to these elements users can scroll the contents of the table independently of the header and footer.

Attributes

Attributes (属性)

AttributeValueDescription
alignright
       left

(左)

       center

(中心)

       justify

(v.辨明 ,认为无罪)

       char|Sets horizontal alignment of the content inside the  \<tfoot>   element.

This attribute is not supported by HTML5.| |bgcolor|bgcolor|Sets the background color of the rows inside the <tfoot> element.

This attribute is not supported by HTML5.| |char|character|Specifies the alignment of the content inside the <tfoot> element to a character. Is used only when the attribute align=“char”.

This attribute is not supported by HTML5.| |charoff|number|Specifies the number of characters the content inside the <tfoot> element will be aligned from the character specified by the charattribute. Is used only when the attribute align=“char”.

This attribute is not supported by HTML5.| |valign|top

       bottom

(底部)

       middle

(中 ,中间)

       baseline|Specifies a vertical alignment of the content inside the\<tfoot>  element. 

This attribute is not supported by HTML5.|

The <tfoot> tag also supports the Global Attributes and the Event Attributes.

How to style <tfoot> tag? Common properties to alter the visual weight/emphasis/size of text in <tfoot> tag:

CSS font-style property sets the style of the font. normal | italic | oblique | initial | inherit. CSS font-family property specifies a prioritized list of one or more font family names and/or generic family names for the selected element. CSS font-size property sets the size of the font. CSS font-weight property defines whether the font should be bold or thick. CSS text-transform property controls text case and capitalization. CSS text-decoration property specifies the decoration added to text, and is a shorthand property for text-decoration-line, text-decoration-color, text-decoration-style.

Coloring text in <tfoot> tag:

CSS color property describes the color of the text content and text decorations. CSS background-color property sets the background color of an element.

Text layout styles for <tfoot> tag:

CSS text-indent property specifies the indentation of the first line in a text block. CSS text-overflow property specifies how overflowed content that is not displayed should be signalled to the user. CSS white-space property specifies how white-space inside an element is handled. CSS word-break property specifies where the lines should be broken.

Other properties worth looking at for <tfoot> tag:

CSS text-shadow property adds shadow to text. CSS text-align-last property sets the alignment of the last line of the text. CSS line-height property specifies the height of a line. CSS letter-spacing property defines the spaces between letters/characters in a text. CSS word-spacing property sets the spacing between words.



请遵守《互联网环境法规》文明发言,欢迎讨论问题
扫码反馈

扫一扫,反馈当前页面

咨询反馈
扫码关注
返回顶部