为什么Firefox突出显示红色的HTML过渡文档类型?

IMB*_*IMB 8 html firefox doctype

看起来Firefox正在将其视为错误.这是什么意思?

在此输入图像描述

如果我将其更改为:Firefox,它会正常对待它:

<!DOCTYPE html>
<html>
Run Code Online (Sandbox Code Playgroud)

顺便说一下,我使用的是Firefox 12.0

nav*_*een 10

如果您将鼠标悬停在该红线上,Firefox会为您提供答案.

几乎标准模式doctype.预期“<!DOCTYPE html>”

View Source的标记也暗示它是一个错误的doctype

<span class="error doctype" title="Almost standards mode doctype. Expected “<!DOCTYPE html>”.">
    &lt;!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"&gt;
</span> 
Run Code Online (Sandbox Code Playgroud)

关键是,Firefox希望<!DOCTYPE html>作为标准模式doc-type.

更新:

摘自上面给出的链接.

示例中显示的DOCTYPE <!DOCTYPE html>是最简单的,也是HTML5推荐的DOCTYPE .早期版本的HTML标准推荐了其他版本,但今天所有现有的浏览器都将使用此DOCTYPE的完整标准模式,即使是过时的Internet Explorer 6.没有合理的理由使用更复杂的DOCTYPE.如果你使用另一个DOCTYPE,你可能会冒险选择一个,这会触发几乎标准模式或怪癖模式.

  • @IMB - 是的,使用HTML5 doctype很好:请参阅http://stackoverflow.com/questions/5935065/which-mode-is-ie6-if-doctype-is-html-as-html5/5935116#5935116 (2认同)