I'd like to use a <tfoot>
tag in a table to be semantically correct, but it keeps showing up at the the top of my table. Is there a way to tell it to display at the bottom?
views:
200answers:
4If by "top of my table" you mean above the tbody
, this is "By Design": http://www.w3schools.com/tags/tag_tfoot.asp
You can't fault it for working the way it's suppose to :)
As Mr. Sampson said the w3schools.com site clearly states that the tfoot tag must be present in the code before the tbody tag.
However the information contained in the tfoot tag should be rendered after the tbody tag. If you are having issues with the tfoot row rendering before your tbody rows I would take a look at your CSS code. Firebug is great for finding strange CSS issues.
Your table should look like the following:
<table>
<thead>...</thead>
<tfoot>...</tfoot>
<tbody>...</tbody>
</table>
with tfoot
appearing above tbody
. It will render, though, at the bottom of the table
As others have said, tfoot
is defined before the tbody
but rendered afterwards. This is by design and doesn't change the semantics (a table has a head, a foot and a body - the order of these doesn't matter)
The reason it's done this way is so that the foot can be loaded and displayed on screen while the body is still downloading, so you can still read the summary information you have in the foot. It's virtually moot these days, but with a slow connection and a massive table, you might still see the benefits.