Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

thead, tfoot and tbody order in HTML5

Tags:

html

I was reading in a forum about <tfoot> element that it must come after <thead> element. In contrast I saw some people use the order <thead><tbody><tfoot>. So what is the correct and best to follow order?

like image 609
miami Avatar asked Sep 19 '13 18:09

miami


2 Answers

According to the W3 specs, tfoot has to come before tbody. (Links to specs here -> Why do internal TABLE sections have to go THEAD TFOOT TBODY to validate?)

This was done to allow the header and footer of a table to load first, before loading in a variable amount of body data, which would otherwise possibly block the loading of the table footer.

like image 150
Marijke Luttekes Avatar answered Oct 14 '22 07:10

Marijke Luttekes


In the HTML 5.1 spec, <tfoot> can only come after <tbody>.

In this order: optionally a caption element, followed by zero or more colgroup elements, followed optionally by a thead element, followed by either zero or more tbody elements or one or more tr elements, followed optionally by a tfoot element, optionally intermixed with one or more script-supporting elements.

https://www.w3.org/TR/html51/tabular-data.html#tabular-data

like image 40
Mats Lundström Avatar answered Oct 14 '22 05:10

Mats Lundström