<tfoot> Tag in HTML | Defining Table Footer

The <tfoot> tag in HTML is used to define a footer section for a table. It typically contains summary information or totals for columns, and it appears at the bottom of the table. This tag is used along with <thead> (table header) and <tbody> (table body) to create a structured, accessible, and well-organized table.

Key Points on <tfoot> Tag:

Syntax of <tfoot> Tag:

Syntax Example

<table>
            <thead>
                <tr>
                    <th>Header 1</th>
                    <th>Header 2</th>
                </tr>
            </thead>
            <tfoot>
                <tr>
                    <td>Footer 1</td>
                    <td>Footer 2</td>
                </tr>
            </tfoot>
            <tbody>
                <tr>
                    <td>Data 1</td>
                    <td>Data 2</td>
                </tr>
            </tbody>
        </table>

Example of <tfoot> Tag in HTML:

This example demonstrates the use of the <tfoot> tag to define a footer in a table, displaying total values for the table data.

Code Example

<table border="1">
            <thead>
                <tr>
                    <th>Product</th>
                    <th>Price</th>
                </tr>
            </thead>
            <tfoot>
                <tr>
                    <td>Total</td>
                    <td>$30</td>
                </tr>
            </tfoot>
            <tbody>
                <tr>
                    <td>Item 1</td>
                    <td>$10</td>
                </tr>
                <tr>
                    <td>Item 2</td>
                    <td>$20</td>
                </tr>
            </tbody>
        </table>

Output

Product Price
Total $30
Item 1 $10
Item 2 $20

Attributes of <tfoot> Tag:

Advantages of Using <tfoot> Tag:

The <tfoot> tag is a valuable addition to HTML tables, providing a clear way to organize footer content like totals or summary information, making tables more readable and accessible.