为什么firebug添加< tbody>到< table>? [英] Why does firebug add <tbody> to <table>?

查看:69
本文介绍了为什么firebug添加< tbody>到< table>?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我查看了html源代码,没有< tbody> ,但是通过HTML选项卡中的firebug进行查看时,< tbody> ; 出现。任何想法为什么?

I viewed the html source code, there is no <tbody>, but when viewed via firebug in the HTML tab, <tbody> appears. Any idea why?

推荐答案

总结Bobince,Kieron,Alohci等人的答案和评论中给出的出色解释: / p>

To summarize the excellent explanations given in the answers and comments by bobince, Kieron, Alohci and others:


  1. Firebug只显示已解析页面的DOM。由于复杂的HTML解析规则,DOM将与源HTML不同(在某种意义上)

  2. 在这种情况下, TBODY 元素由HTML解析器添加。请注意,这个奇怪的解析仅限于text / html文档,而在XHTML中,DOM与源XML密切相关。


    • 此行为已在 HTML 4 table 的内容模型(允许的小孩)是(CAPTION ?,(COL * | COLGROUP *),THEAD?,TFOOT?,TBODY +) / code> - tr 只允许在 tbody !规范说, tbody 的开始标记是可选的,这应该是指如果HTML解析器遇到 tr 直接在中,插入作者忽略的 tbody 开始标签。

    • <为了使事情更清楚HTML 5定义非常详细的解析规则,特别是在这种情况下:当插入模式为表时,令牌必须如下处理:[...]标签名称为:td,th,tr - >似乎已经看到标签名为tbody的开始标记令牌,然后重新处理当前的令牌。
  1. Firebug just displays the DOM of the parsed page. Due to complicated HTML parsing rules, the DOM will "differ" (in some sense) from the source HTML.
  2. In this case the TBODY element in the DOM is added by the HTML parser. Note that this weird parsing is limited to text/html documents and in XHTML the DOM corresponds closely to the source XML.
    • This behavior was specified in HTML 4. The content model (allowed children) for table is (CAPTION?, (COL*|COLGROUP*), THEAD?, TFOOT?, TBODY+) -- trs are only allowed in tbody! The spec says that tbody's start tag is optional, which is supposed to mean that if the HTML parser encounters tr directly inside a table it inserts the tbody start tag omitted by the author.
    • To make matters more clear HTML 5 defines very detailed parsing rules, in particular for this case: "When the insertion mode is "in table", tokens must be handled as follows: [...] A start tag whose tag name is one of: "td", "th", "tr" -> Act as if a start tag token with the tag name "tbody" had been seen, then reprocess the current token."

这篇关于为什么firebug添加&lt; tbody&gt;到&lt; table&gt;?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆