Just a short question today.

Is the W3C html validator broken? Today, I got a piece of code a jsp tag is rendering for a results table. It contains a tfoot for some information that is supposed to go below the results, so it is semanticly correct. But according to the w3c validator it isn’t valid HTML…

The code is as follows:

<table> <thead> <tr><th>header</th></tr> </thead> <tbody> <tr><td>results</td></tr> </tbody> <tfoot> <tr><td>results</td></tr> </tfoot> </table>

Yet the message I get from the (#$%@) validator is that is not allowed there. After some browsing I came up with a solution which suprised me and maybe will be of some use for others…The code above is indeed not as valid as it may seem. The tfoot is supposed to go after the thead and before the tbody. Having read the section of the w3c specifications about it, it does makes sense.

TFOOT must appear before TBODY within a TABLE definition so that user agents can render the foot before receiving all of the (potentially numerous) rows of data.

So to conclude, after more than 10 years of web development, you can still learn something.

In the future I (and hopefully you too) will mark up my tables like this

<table> <thead> <tr><th>header</th></tr> </thead> <tfoot> <tr><td>results</td></tr> </tfoot> <tbody> <tr><td>results</td></tr> </tbody> </table>

I hope this was helpfull for all of my readers…