HTML5 - 2017 订购 <tbody> 和 <tfoot> 元素的正确方法?

标签 html html-table w3c-validation

各位! 我在许多文章和类(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 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.

注意它说 tfoottbody 之后允许但在tbody之前不再说允许.

关于HTML5 - 2017 订购 <tbody> 和 <tfoot> 元素的正确方法?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44501960/

相关文章:

html - Facebook 元标签搞砸了 w3c 验证

Javascript 将元素导航到最近的输入或选择元素

php - websocket的服务器端需要什么?

PHP HTML 表格太宽

css - IE11 的 HTML 转换问题

jquery - 如果父元素也有鼠标悬停,如何为子元素触发鼠标悬停事件?

javascript - 使用 localStorage 简化代码

jquery - jquery 验证是如何工作的?

html - "The language attribute on the script element is obsolete. You can safely omit it."?

javascript - HTML5 : element <group>