- Home
- /
- Tutorials
- /
- HTML Tutorial
- /
- HTML <tfoot> Tag
HTML Tags
HTML <tfoot> Tag
The tfoot tag holds the footer rows of a table, usually totals or a summary line. It goes at the end of the table, after the tbody, and stays at the bottom when the table is printed across several pages.
Together with thead and tbody, it splits a table into its three parts: header, body and footer.
Syntax
html
<table>
<thead>
<tr>
<th>Header 1</th>
<th>Header 2</th>
</tr>
</thead>
<tbody>
<tr>
<td>Data 1</td>
<td>Data 2</td>
</tr>
</tbody>
<tfoot>
<tr>
<td colspan="2">Footer Content</td>
</tr>
</tfoot>
</table>It has no attributes of its own, only the global ones such as id, class and style.
Example
html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Tfoot Tag Example</title>
<style>
table {
border-collapse: collapse;
width: 70%;
margin: 20px auto;
text-align: center;
}
thead {
background-color: #29AB87;
color: white;
}
tfoot {
background-color: #e0f3ec;
font-weight: bold;
color: #333;
}
th, td {
border: 1px solid #555;
padding: 10px;
}
tbody tr:nth-child(even) {
background-color: #f9f9f9;
}
</style>
</head>
<body>
<h2>HTML Table with Tfoot Example</h2>
<table>
<thead>
<tr>
<th>Item</th>
<th>Price (₹)</th>
</tr>
</thead>
<tbody>
<tr>
<td>Notebook</td>
<td>50</td>
</tr>
<tr>
<td>Pencil</td>
<td>10</td>
</tr>
<tr>
<td>Eraser</td>
<td>5</td>
</tr>
</tbody>
<tfoot>
<tr>
<td>Total</td>
<td>₹65</td>
</tr>
</tfoot>
</table>
</body>
</html>The table lists three items and their prices, with a bold "Total: ₹65" row at the bottom in a light green band. That row is inside <tfoot>, which is styled separately in the CSS.
Where to put tfoot
Write it after <tbody>, as the last part of the table. You may read in older tutorials that <tfoot> should come before <tbody>; that was allowed in HTML4, but current HTML expects it at the end. Browsers display it at the bottom either way.
Browser Support
Chrome | Edge | Firefox | Safari | Opera | IE9+ |
|---|---|---|---|---|---|
| Yes | Yes | Yes | Yes | Yes | Yes |
Good to know
HTML <tfoot> Tag exercises
Add a footer row
Make a table with a body row Pen, 10 and a footer row Total, 10.
Result
