html <h3><dt> 中的标签标签 [英] html <h3> tag in <dt> tag
问题描述
我注意到 Firefox/Firebug 中出现了一个尴尬的情况:
I've noticed an awkward occurence in Firefox/Firebug:
<dl>
<dt><h3>test</h3></dt>
<dd>stuff</dd>
</dl>
渲染成这样
<dl>
<dt></dt>
<h3>test</h3>
<dd>stuff</dd>
</dl>
我以前从未见过这种情况.谁能解释一下原因?
I've never seen this happen before. Can anyone explain why?
推荐答案
可能是因为它是无效的 XHTML 而这就是 Firefox 错误恢复的工作原理:
Probably because it's invalid XHTML and this is how the Firefox's error recovery works:
第 14 行,第 12 列:文档类型不允许在此处使用元素h3";缺少object"、ins"、del"、map"、button"开始标签之一
Line 14, Column 12: document type does not allow element "h3" here; missing one of "object", "ins", "del", "map", "button" start-tag
FWIW,我测试了 Chrome、IE 和 Opera,但没有一个表现出相同的行为.这是为什么您应该编写有效标记而不是依赖解析器的错误恢复的有力论据 - 浏览器以自己的方式处理错误.
FWIW, I tested Chrome, IE and Opera and none of them exhibited the same behavior. This is a solid argument for why you should write valid markup and not rely on the parser's error recovery - browsers handle errors in their own way.
这篇关于html <h3><dt> 中的标签标签的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!