The <tfoot> tag in HTML is used to define the footer section of a table, typically for summary content.
- Used to provide a footer group of content in an HTML table along with <thead> and <tbody>.
- Acts as a child of <table> and a parent of <tr> and <td> tags.
- Must contain one or more <tr> elements inside it.
Syntax
<tfoot>
// Table footer contents...
</tfoot>
Attributes
The attributes for the <tfoot> tag are supported by HTML4.1 only but are now deprecated in HTML5. To get the same effect use CSS to style text-align and vertical align.
- align: The align attribute is used to set the horizontal alignment of the text content.
- valign: The valign attribute is used to set the vertical alignment of the text content.
- char: The char attribute is used to align the content in a cell based on a specific character.
- charoff: The charoff attribute is used to specify the number of characters offset for alignment based on the char attribute.
Note: The <tfoot> tag also supports the Global Attributes and Event Attributes in HTML.
Example: In this example, we will see how to implement the above tag in HTML.
<!--Driver Code Starts-->
<!DOCTYPE html>
<html>
<body>
<center>
<h1>GeeksforGeeks</h1>
<h2>tfoot Tag</h2>
<table>
<thead>
<tr>
<th>Name</th>
<th>User Id</th>
</tr>
</thead>
<tbody>
<tr>
<td>Ram</td>
<td>@ram_b</td>
</tr>
<tr>
<td>Shashank</td>
<td>@shashankla</td>
</tr>
<tr>
<td>Rahman</td>
<td>@rahamD</td>
</tr>
</tbody>
<!-- tfoot tag starts from here -->
<!--Driver Code Ends-->
<tfoot>
<tr>
<td>Total user</td>
<td>4</td>
</tr>
</tfoot>
<!--Driver Code Starts-->
<!-- tfoot tag ends here -->
</table>
</center>
</body>
</html>
<!--Driver Code Ends-->