Dofactory.com
Dofactory.com

HTML <tfoot> style Attribute

A style attribute on a <tfoot> tag assigns a unique style to the table footer.

Its value is CSS that defines the appearance of the tfoot element.

Example

#

A style attribute on a <tfoot> element.

First Name Last Name
Denice Hobermann
Paulo Cornell
Jane Hollander
Number of finalists: 3
<style>
  table.tb { width: 350px; border-collapse: collapse; }
  .tb th, .tb td { border: solid 1px #777; padding: 5px; }
</style>

<table class="tb">
  <thead>
    <tr>
      <th>First Name</th>
      <th>Last Name</th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <td>Denice</td>
      <td>Hobermann</td>
    </tr>
    <tr>
      <td>Paulo</td>
      <td>Cornell</td>
    </tr>
    <tr>
      <td>Jane</td>
      <td>Hollander</td>
    </tr>
  </tbody>
  <tfoot style="background-color:lightblue;">
    <tr>
      <td colspan="2">Number of finalists: 3</td>
    </tr>
  </tfoot>
</table>

Using style

The style attribute specifies the style, i.e. look and feel, of the <tfoot> element.

A style contains any number of CSS property/value pairs, separated by semicolons (;).

The style attribute overrides any other style that was defined in a <style> tag or an external CSS file.

This inline styling affects the current <tfoot> element only.


Syntax

<tfoot style="CSS-styles">

Values

#

Value Description
CSS-styles One or more CSS property/value pairs separated by semicolons (;).

More Examples

A style attribute on a <tfoot> element.
Clicking the button toggles the table footer to dark mode.

First Name Last Name
Denice Hobermann
Paulo Cornell
Jane Hollander
Number of finalists: 3

<style>
  table.tbl { width: 350px; border-collapse: collapse; }
  .tbl th, .tbl td { border: solid 1px #777; padding: 5px; }
</style>

<table class="tbl">
  <thead>
    <tr>
      <th>First Name</th>
      <th>Last Name</th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <td>Denice</td>
      <td>Hobermann</td>
    </tr>
    <tr>
      <td>Paulo</td>
      <td>Cornell</td>
    </tr>
    <tr>
      <td>Jane</td>
      <td>Hollander</td>
    </tr>
  </tbody>
  <tfoot id="mytfoot" style="background-color:lightblue;">
    <tr>
      <td colspan="2">Number of finalists: 3</td>
    </tr>
  </tfoot>
</table>

<br />
<button onclick="toggle();">Toggle style</button>

<script>
  let toggle = () => {
     let element = document.getElementById("mytfoot");

     if (element.style.backgroundColor === "lightblue") {
       element.style.backgroundColor = "#222";
       element.style.color = "#fff";
    } else {
       element.style.backgroundColor = "lightblue";
       element.style.color = "#222";
    }
  }
</script>

Code explanation

The style attribute assigns a background and text colors to the <tfoot> element.

Clicking the button calls JavaScript which toggles the background and text color to different value.


Browser support

Here is when style support started for each browser:

Chrome
1.0 Sep 2008
Firefox
1.0 Sep 2002
IE/Edge
1.0 Aug 1995
Opera
1.0 Jan 2006
Safari
1.0 Jan 2003

You may also like

 Back to <tfoot>

Author: Jack Poorte
Published: Jun 20 2021
Last Reviewed: Sep 30 2023


Quick question: what's your favorite/least favorite part of Dofactory?


Guides