**`<tfoot>`** wraps summary rows — totals, subtotals, averages — that relate to the data in `<tbody>` above it. Interestingly, in the HTML source you can actually place `<tfoot>` BEFORE `<tbody>` (right after `<thead>`), and browsers will still render it visually at the bottom of the table; this ordering flexibility exists so a browser can render/print the summary footer without needing to first process the entire (potentially huge) body of data.
1Understanding <tfoot>
`<tfoot>` wraps summary rows — totals, subtotals, averages — that relate to the data in <tbody> above it. Interestingly, in the HTML source you can actually place <tfoot> BEFORE <tbody> (right after <thead>), and browsers will still render it visually at the bottom of the table; this ordering flexibility exists so a browser can render/print the summary footer without needing to first process the entire (potentially huge) body of data.
Like <thead>, browsers can repeat <tfoot> content at the bottom of each printed page for a long table, giving the reader a running summary alongside the header on every page.
<table>
<thead><tr><th>Item</th><th>Price</th></tr></thead>
<tbody>
<tr><td>Book</td><td>$12</td></tr>
<tr><td>Pen</td><td>$2</td></tr>
</tbody>
<tfoot>
<tr><td>Total</td><td>$14</td></tr>
</tfoot>
</table>2Practical Example
Here is a real-world application of <tfoot> showing how it is used in production HTML.
<!-- tfoot placed early in the source, still renders at the bottom -->
<table>
<thead><tr><th>Item</th><th>Price</th></tr></thead>
<tfoot><tr><td>Total</td><td>$14</td></tr></tfoot>
<tbody>
<tr><td>Book</td><td>$12</td></tr>
<tr><td>Pen</td><td>$2</td></tr>
</tbody>
</table>3Best Practices
Follow these guidelines when working with <tfoot>:
1. Use <tfoot> for totals, subtotals, or summary rows, not regular data
2. Feel free to place <tfoot> in the source right after <thead> if that better fits how your data is generated — it still renders at the bottom
3. Style <tfoot> distinctly (e.g. bold, top border) to visually separate it from the data above
Tip: Like <thead>, browsers can repeat <tfoot> content at the bottom of each printed page for a long table, giving the reader a running summary alongside the header on every page.
<table>
<thead><tr><th>Item</th><th>Price</th></tr></thead>
<tbody>
<tr><td>Book</td><td>$12</td></tr>
<tr><td>Pen</td><td>$2</td></tr>
</tbody>
<tfoot>
<tr><td>Total</td><td>$14</td></tr>
</tfoot>
</table>