HTML <tfoot> Tag

HTML Tag


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

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

Example

<!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
        <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

tfoot example

Attributes

AttributeValueDescription
alignright
left
center
justify
char
Sets horizontal alignment of the content inside the <tfoot> element.
This attribute is not supported by HTML5.
bgcolorbgcolorSets the background color of the rows inside the <tfoot> element.
This attribute is not supported by HTML5.
charcharacterSpecifies 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.
charoffnumberSpecifies 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.
valigntop
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 signaled 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: Allow setting the spacing between words.
Reactions

Post a Comment

0 Comments

close