各位!
我在许多文章和类(class)中看到 <tfoot>
在表格元素中应放在 <tbody>
之前元素。对...但是,当我这样做时,验证器 ( https://validator.w3.org ) 告诉我这是错误的,我不能使用 <tfoot>
在这种情况下。所以我决定把 <tfoot>
在<tbody>
之后并且验证器没有在我的代码中发现任何错误。
那么...无论如何,正确的方法是什么?
我还发现该规范似乎与其自身相矛盾:https://www.w3.org/TR/html51/tabular-data.html#the-tfoot-element
最佳答案
<tfoot>
规范规则 were changed in December 2015 to disallow <tfoot>
before <tbody>
due to the accessibility issues it was causing .
就W3C规范而言,寻找相关要求的地方实际上是在the part of the spec that states the rules for what is allowed in the <table>
element中。 ,它说:
In this order: optionally a
caption
element, followed by zero or morecolgroup
elements, followed optionally by athead
element, followed by either zero or moretbody
elements or one or moretr
elements, followed optionally by atfoot
element, optionally intermixed with one or more script-supporting elements.
注意它说 tfoot
在 tbody
之后允许但在tbody
之前不再说允许.
关于HTML5 - 2017 订购 <tbody> 和 <tfoot> 元素的正确方法?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44501960/