Adding Footers to Tables

5 min read

Adding Footers to Tables in HTML — A Complete Beginner’s Guide

If you’ve ever created an HTML table for invoices, product listings, or reports, you may have wondered how to display totals or summary information at the bottom. That’s where the <tfoot> element comes in. In this guide, you’ll learn how to use table footers effectively to make your tables cleaner, more professional, and more accessible. You’ll also see real-life business examples and ready-to-use code samples.

What Is the Table Footer (<tfoot>)?

The <tfoot> tag defines a section of a table that appears after the main body (<tbody>) and typically contains summary rows, totals, or notes. Even though it is placed after <tbody> in your HTML, browsers can render it before or after depending on their layout logic.

A footer is especially useful in business contexts such as invoices, sales reports, or data summaries where you need to display totals or remarks at the end of a dataset.

Example: Invoice Table with Footer

<table>
  <thead>
    <tr>
      <th>Item</th>
      <th>Quantity</th>
      <th>Price</th>
    </tr>
  </thead>

  <tbody>
    <tr>
      <td>Laptop</td>
      <td>2</td>
      <td>$1,000</td>
    </tr>
    <tr>
      <td>Mouse</td>
      <td>5</td>
      <td>$25</td>
    </tr>
  </tbody>

  <tfoot>
    <tr>
      <td colspan="2"><strong>Total</strong></td>
      <td><strong>$2,125</strong></td>
    </tr>
  </tfoot>
</table>

Why Use a Table Footer?

  • Improves readability: Separates summary data from the rest of the table.
  • Better for accessibility: Screen readers can identify table sections, helping users understand content structure.
  • Styling convenience: You can apply unique CSS styles to <tfoot> to highlight totals or remarks.

How to Style the Table Footer

CSS can make your footer stand out and visually indicate that it represents totals or final notes. Here’s an example:

Example: Styling the Footer

table {
  width: 100%;
  border-collapse: collapse;
}

th, td {
  padding: 10px;
  border: 1px solid #ccc;
}

thead {
  background-color: #f9fafb;
}

tfoot {
  background-color: #fff8e6;
  font-weight: bold;
  color: #333;
}

The footer background color and bold text create visual distinction, making totals or summaries easier to spot. You can also align text or add currency symbols for financial data.

Real-Life Business Examples

1. Sales Summary Table

Many eCommerce businesses use table footers to calculate the final total of sales or taxes. This helps customers and accountants review totals quickly.

<tfoot>
  <tr>
    <td colspan="2">Subtotal</td>
    <td>$980</td>
  </tr>
  <tr>
    <td colspan="2">Tax (10%)</td>
    <td>$98</td>
  </tr>
  <tr>
    <td colspan="2"><strong>Total</strong></td>
    <td><strong>$1,078</strong></td>
  </tr>
</tfoot>

2. Financial Report Summary

In financial dashboards or spreadsheets, the footer summarizes the sum of multiple columns, helping decision-makers quickly understand profits or expenses.

3. Product Comparison Chart

When comparing products, the footer can display overall ratings, average prices, or final recommendations.

Common Mistakes to Avoid

  • Placing <tfoot> before <tbody>: Though HTML5 allows flexible ordering, for clarity and maintainability, keep <tfoot> after the table body.
  • Forgetting colspan or rowspan: Totals often need merged cells; forgetting this can break your layout.
  • Neglecting mobile responsiveness: Use CSS media queries or flexbox to ensure table footers remain readable on small screens.

SEO and Accessibility Tips

To make your table footers not just beautiful but discoverable and accessible:

  • Use semantic HTML elements like <caption> to describe table content.
  • Include descriptive text for assistive technologies (e.g., “Total sales amount” instead of “Total”).
  • For search optimization, use relevant keywords like HTML table footer example, invoice table template, and business report totals.

Final Thoughts

The <tfoot> element may seem small, but it adds clarity, professionalism, and structure to your data. Whether you’re building a sales dashboard, invoice generator, or analytics report, using table footers properly makes your content more accessible and easier to read.

Try adding footers to your next project and watch how it transforms the presentation of your business data.

Mastering HTML Table Structures and Layouts

Mastering HTML Table Structures and Layouts

Table Layout and Styling Techniques
software
View course

Course Lessons