The <tfoot>
HTML element is used to group footer content in tables. It contains information about the data that has been displayed in the table and provides a summary of the table’s contents. The <tfoot>
tag must be placed inside a <table>
tag, and it must be placed before the <tbody>
tag.
Here is an example of how to use the <tfoot>
tag:
<table>
<thead>
<tr>
<th>Name</th>
<th>Age</th>
<th>Occupation</th>
</tr>
</thead>
<tbody>
<tr>
<td>John</td>
<td>30</td>
<td>Engineer</td>
</tr>
<tr>
<td>Mary</td>
<td>25</td>
<td>Doctor</td>
</tr>
</tbody>
<tfoot>
<tr>
<td>Total</td>
<td>55</td>
<td></td>
</tr>
</tfoot>
</table>
In this example, the <tfoot>
tag contains a single row with three cells. The first cell contains the word “Total,” indicating that it is providing a summary of the data in the table. The second cell contains the sum of the ages (30 + 25 = 55), and the third cell is left blank since there is no occupation information in the <tbody>
tag.
Attributes
The following attributes can be applied to the <tfoot>
tag:
align
– This attribute specifies the horizontal alignment of the table’s data. The possible values are “left”, “center”, and “right”.valign
– This attribute specifies the vertical alignment of the table’s data. The possible values are “top,” “middle,” and “bottom.”charset
– This attribute specifies the character set used in the table data.charoff
– This attribute specifies the number of characters that should be shifted for each cell in the table.width
– This attribute specifies the width of the table.bgcolor
– This attribute specifies the background color of the table.cellspacing
– This attribute specifies the space between cells in the table.cellpadding
– This attribute specifies the padding within cells in the table.border
– This attribute specifies the width and style of the border around the table.frame
– This attribute specifies the type of frame that should be drawn around the table. The possible values are “void,” “above,” “below,” “sides,” “lhs,” “this,” “sides,” “box,” “border,” and “none.”
Blog Article: Understanding the <tfoot>
Tag in HTML
What is the <tfoot>
Tag?
The <tfoot>
tag is an HTML element that is used to group footer content in tables. It contains information about the data displayed in the table and provides a summary of the table’s contents. The <tfoot>
tag must be placed inside a <table>
tag, and it must be placed before the <tbody>
tag.
Example of Usage
Here is an example of how to use the <tfoot>
tag:
<table>
<thead>
<tr>
<th>Name</th>
<th>Age</th>
<th>Occupation</th>
</tr>
</thead>
<tbody>
<tr>
<td>John</td>
<td>30</td>
<td>Engineer</td>
</tr>
<tr>
<td>Mary</td>
<td>25</td>
<td>Doctor</td>
</tr>
</tbody>
<tfoot>
<tr>
<td>Total</td>
<td>55</td>
<td></td>
</tr>
</tfoot>
</table>
In this example, the <tfoot>
tag contains a single row with three cells. The first cell contains the word “Total,” indicating that it is providing a summary of the data in the table. The second cell contains the sum of the ages (30 + 25 = 55), and the third cell is left blank since there is no occupation information in the <tbody>
tag.
Attributes of the <tfoot>
Tag
The following attributes can be applied to the <tfoot>
tag:
align
– This attribute specifies the horizontal alignment of the table’s data. The possible values are “left”, “center”, and “right”.valign
– This attribute specifies the vertical alignment of the table’s data. The possible values are “top”, “middle”, and “bottom”.charset
– This attribute specifies the character set used in the table data.charoff
– This attribute specifies the number of characters that should be shifted for each cell in the table.width
– This attribute specifies the width of the table.bgcolor
– This attribute specifies the background color of the table.cellspacing
– This attribute specifies the space between cells in the table.cellpadding
– This attribute specifies the padding within cells in the table.border
– This attribute specifies the width and style of the border around the table.frame
– This attribute specifies the type of frame that should be drawn around the table. The possible values are “void”, “above”, “below”, “hsides”, “lhs”, “rhss”, “vsides”, “box”, “border”, and “none”.
Conclusion
The <tfoot>
tag is a useful HTML element for providing a summary of the data displayed in tables. It can be used to group footer content and provide important information about the table’s contents. By using the appropriate attributes, web developers can customize the appearance and behavior of the <tfoot>
tag to meet their specific needs.