- c - 在位数组中找到第一个零
- linux - Unix 显示有关匹配两种模式之一的文件的信息
- 正则表达式替换多个文件
- linux - 隐藏来自 xtrace 的命令
我知道不同的文档类型本质上是关于 html 的合规性的,但是你指定的文档类型有什么区别呢?浏览器是否会根据文档类型以不同方式处理相同的代码?谢谢
更新 - 如果没有指定文档类型,大多数答案都提到可以关闭怪癖模式。但是 xhtml 和 html 4.01 之间有什么不同呢?
最佳答案
最重要的是有没有文档类型。如果不这样做,浏览器将以“怪癖”模式而不是标准模式工作,并且许多事情会略有不同。如果您有一个——任何一个——通常会在浏览器中激活更多符合标准的行为。
参见 this article有关文档类型在各种不同浏览器上的作用以及模式(怪癖、标准、几乎标准等)的详细信息,不同的浏览器都有。引用相关部分:
Modes for text/html Content
The choice of the mode for text/html content depends on doctype sniffing (discussed later in this document). In IE8 and IE9, the mode also depends on other factors. However, by default even in IE8 and IE9, the mode depends on the doctype for non-intranet sites that are not on a blacklist supplied by Microsoft.
It cannot be stressed enough that the exact behavior of the modes varies from browser to browser even though discussion in this document has been unified.
Quirks Mode
In the Quirks mode the browsers violate contemporary Web format specifications in order to avoid “breaking” pages authored according to practices that were prevalent in the late 1990s. Different browsers implement different quirks. In Internet Explorer 6, 7, 8 and 9, the Quirks mode is effectively frozen IE 5.5. In other browsers, the Quirks mode is a handful of deviations from the Almost Standards mode.
If you are authoring new pages now, you are supposed to comply with the relevant specifications (CSS 2.1 in particular) and use the Standards mode.
Standards Mode
In the Standards mode the browsers try to give conforming documents the specification-wise correct treatment to the extent implemented in a particular browser.
Since different browsers are at different stages of compliance, the Standards mode isn’t a single target, either.
HTML 5 calls this mode the “no quirks mode”.
Almost Standards Mode
Firefox, Safari, Chrome, Opera (since 7.5), IE8 and IE9 also have a mode known as “the Almost Standards mode”, which implements the vertical sizing of table cells traditionally and not rigorously according to the CSS2 specification. Mac IE 5, Windows IE 6 and 7, Opera prior to 7.5 and Konqueror do not need an Almost Standards mode, because they don’t implement the vertical sizing of table cells rigorously according to the CSS2 specification in their respective Standards modes anyway. In fact, their Standards modes are closer to the Almost Standards mode than to the Standards mode of newer browsers.
HTML 5 calls this mode the “limited quirks mode”.
IE7 Mode
IE8 and IE9 have a mode that is mostly a frozen copy of the mode that was the Standards mode in IE7. Other browsers do not have a mode like this, and this mode is not specified by HTML5.
IE8 Standards Mode
IE9 has a mode that is mostly a frozen copy of the mode that was the Standards mode in IE8. Other browsers do not have a mode like this, and this mode is not specified by HTML5.
IE8 Almost Standards Mode
IE9 has a mode that is mostly a frozen copy of the mode that was the Almost Standards mode in IE8. Other browsers do not have a mode like this, and this mode is not specified by HTML5.
...但请参阅文章以获取完整讨论。
关于html - DOCTYPE 的意义何在?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6213242/
我有一张 table People (First_Name, Last_Name)。此表包含与示例中一样重复的记录(并非所有行都重复): First_Name Last_Name John
我用 Java 编写过很多程序,之前也涉足过 C++。我在各种 C++ 书籍中阅读了有关指针的内容,并完成了书籍中的各种示例。 我了解指针的基础知识,但有一件事我一直不清楚。指针在现实世界中的应用是什
线 .Mappings(m => m.FluentMappings.AddFromAssemblyOf() 它有什么作用?它会在派生自 ClassMap 的 Product 类的程序集中查找任
我有用于打印数字的自定义打印功能。我制作了一个 ASCII 版本和一个 UTF-16LE 版本。 UTF-16LE 版本对 0-9 使用全角代码/字符,对十六进制使用 A-F。在调试我的函数时,我注意
这是我的代码片段: float ab(float); 以后 if(ab(temp)
我在一个项目文件中包含以下代码: //begin of the file ((window) => { 'use strict'; class View extends GSM.Event
我一直在到处寻找关于 ? 用法的正确解释。和 *。我注意到我可以使用以下方法拒绝所有用户的访问: 如果我想允许某个组,我应该在其上方添加下一行: 但是当我看到人们使用 ? 时,我开始忘记什么意思,
我正在关注 melon js tutorial .这是在我的 HUD.js 文件的顶部。 game.HUD = game.HUD || {} 我以前在其他例子中见过这个。 namespace.some
我正在处理一个包含数千行代码的文件。我正在第 700 行实现一个算法。我经常不得不离开这些行来检查文件中的其他方法。 导航回到我实际编码的地方通常很痛苦。如果我可以在第 700 行设置一个航路点并为其
我遇到了这段代码 do { if (higherQuality && w > targetWidth) { w /= 2; if (w &
uint8_t * const LCDMem = (uint8_t *) &LCDM3; 此代码在 msp430fg4618 培训套件中用于 lcd 配置。谁能解释一下上述代码的含义? 它允许使用 a
上下文 阅读一些内核代码。 问题 我不明白这行是什么意思 *(void **) &(int[2]){0,PAGE_SIZE}; 还有更多,这是什么意思 {0,PAGE_SIZE} 对我来说,它看起来不
我正在查看 Underscore.js 的源代码库,专门用于 map方法(该页面第 85 行左右,并复制到此处): _.map = function(obj, iterator, context)
很难说出这里要问什么。这个问题模棱两可、含糊不清、不完整、过于宽泛或夸夸其谈,无法以目前的形式得到合理的回答。如需帮助澄清此问题以便重新打开,visit the help center . 关闭 9
我是一名优秀的程序员,十分优秀!