原文地址:https://hsivonen.fi/doctype/

In order to deal both with content written according to Web standards and with content written according to legacy practices that were prevalent in the late 1990s, today’s Web browsers implement various engine modes. This document explains what those modes are and how they are triggered.

Summary for the Impatient

The main conclusion to draw from this article is that you should start all your HTML documents (i.e. anything that gets served as text/html) with <!DOCTYPE html> as the first thing in the source. (Read on to learn why.)

If you want to take extra care to make sure that users of IE8, IE9 or IE10 cannot press a button that makes your site regress as if it was being viewed in IE7, either configure your server to send the HTTP header X-UA-Compatible: IE=Edge for text/html or put <meta http-equiv="X-UA-Compatible" content="IE=Edge"> in thehead of your HTML documents (before any scripts). This will, however, make the HTML document invalid and if you don’t include these IE-specific incantations, the default behavior of IE is reasonable in most cases, so you don’t really needto jump through these IE-specific hoops. (Read on for exceptions.)

The Scope of This Document

This document covers mode switching as it applies to Firefox and other Gecko-based browsers, Safari, Chrome and other WebKit-based browsers, Opera, Konqueror, Internet Explorer for Mac, Internet Explorer for Windows (including Windows Phone) and browsers that embed IE. Instead of referring to the names of browser engines, the names of the best-known browsers using each engine are used instead.

This document focuses on the mode selection mechanism and does not document the exact behaviors of each mode. The purpose of this document is to give you information on how to avoid the legacy modes. The purpose of this document is not to facilitate cherry-picking behaviors by deliberately choosing legacy modes.

The Modes

Here are the various modes:

Common 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 later, the mode also depends on other factors. However, by default even in IE8 and later, the mode depends on the doctype for non-intranet sites that are not on a blacklist supplied by Microsoft. Additionally, there are other factors involved even with IE6 and IE7 if Google Chrome Frame has been installed.

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. Previously, different browsers implemented different quirks. In particular, in Internet Explorer 6, 7, 8 and 9, the Quirks mode is effectively frozen IE 5.5, while in other browsers the Quirks mode has been a handful of deviations from the Almost Standards mode. Recently, browsers have been converging on common behavior in their Quirks modes. Most notably, the primary Quirks mode of IE10 is no longer an imitation of IE 5.5 but seeks to be interoperable with Quirks modes of other browsers. The interoperable quirks are being standardized at the WHATWG.

The primary Quirks mode of IE10 that is like the Quirks modes of other browsers is sometimes referred to as the “interoperable Quirks mode” to distinguish it from the IE 5.5-imitating “Internet Explorer 5 Quirks” mode that IE10 also has.

If you are authoring new page, don’t use the Quirks mode. Just don’t. Use the Standards mode.

Standards Mode

In the Standards mode the browsers try to give 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.

The HTML specification calls this mode the “no quirks mode”.

Almost Standards Mode

Firefox, Safari, Chrome, Opera (since 7.5), IE8, IE9 and IE10 also have a mode known as “the Almost Standards mode”, which implements the vertical sizing of table cells traditionally and not according to the CSS2 specification. Mac IE 5, Windows IE 6 and 7, Opera prior to 7.5 and Konqueror did not need an Almost Standards mode, because they didn’t implement the vertical sizing of table cells 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.

In retrospect, the Web would have been better off by not having the distintion between Standards and Almost Standards, having the Almost Standards behavior as the default and having a CSS property for opting into the behavior that is the default in the Standards mode. Still, you should use the Standards mode—not the Almost Standard mode.

The HTML specification calls this mode the “limited quirks mode”.

The Mode for application/xhtml+xml Content (XML Mode)

In Firefox, Safari, Chrome, Opera and IE9, the application/xhtml+xml HTTP Content-Type (not a meta element nor a doctype!) triggers the XML mode. In the XML mode, these browsers give the specification-wise correct treatment for XML documents to the extent implemented in a particular browser.

IE 6, 7 and 8 did not support application/xhtml+xml. Neither did Mac IE 5.

In the WebKit-based Nokia S60 Browser, the application/xhtml+xml HTTP Content-Type did not trigger the XML mode due to concerns of compatibility with ill-formed content in mobile walled gardens. (Legacy “mobile browsers” didn’t use a real XML parser and, therefore, ill-formed content has been labeled as XML.)

I have not tested the default browser on Symbian3.

I have not tested Konqueror sufficiently to say what exactly happens in that browser.

IE-Specific Additional Modes from Microsoft

The following are additional IE-specific modes that are not specified by HTML5 and that other browsers don’t have. Their activation involves configuration or X-UA-Compatible as an HTTP header or a meta element (discussed below).

Internet Explorer 5 Quirks
In addition to the interoperable Quirks mode, IE10 also has a mode called “Internet Explorer 5 Quirks”, which imitates IE 5.5 and is the mode that was known as the Quirks mode in IE6, IE7, IE8 and IE9.
Internet Explorer 7 Standards

IE8, IE9 and IE10 have a mode that imitates the mode that was the Standards mode in IE7.

Internet Explorer 8 Standards

IE9 and IE10 have a mode that imitates the mode that was the Standards mode in IE8.

Internet Explorer 8 Almost Standards

IE9 and IE10 have a mode that imitates the mode that was the Almost Standards mode in IE8. In the developer tool user interface, this mode is not distinguished from “Internet Explorer 8 Standards”.

Internet Explorer 9 Standards

IE10 has a mode that imitates the mode that was the Standards mode in IE9.

Internet Explorer 9 Almost Standards

IE10 has a mode that imitates the mode that was the Almost Standards mode in IE9. In the developer tool user interface, this mode is not distinguished from “Internet Explorer 9 Standards”.

Internet Explorer 9 XML

IE10 has a mode that imitates the mode that was the XML mode in IE9. In the developer tool user interface, this mode is not distinguished from “Internet Explorer 9 Standards”.

It is worth noting that the imitations of the previous versions of IE are not perfect. Random examples that I have encountered myself include IE7 Standards emulation in a later IE version handling @font-face-liked EOT fonts differently and the IE9 modes of IE10 supporting CSS 2D Transformations without the -ms- when the real IE9 requires the prefix. If you follow the advice given in this document, you won’t be targeting these modes, so the imperfections of the imitations won’t matter to you in production. However, the takeaway for testing is that you’ll be better off testing your site in actual old versions of IE running in a bunch of virtual machines than using the developer tools newer IE versions to make the new version emulate an old version for testing.

IE10 for Windows Phone 8 has all these modes, too—just like IE10 on desktop.

IE-Specific Additional Modes from Google

The following are additional modes available in IE6, IE7, IE8 and IE9 (but not in IE10 on Windows 8 or on Windows 7 as of February 2013) when Google Chrome Frame has been installed.

Chrome Quirks

This mode is the same as the Quirks mode in Google Chrome.

Chrome Standards

This mode is the same as the Standards mode in Google Chrome.

Chrome Almost Standards

This mode is the same as the Almost Standards mode in Google Chrome.

Non-Web Modes

Some engines have modes that are not relevant to Web content. These modes are only mentioned here for completeness. Opera has a WML 2.0 mode. WebKit on Mac OS X 10.5 had a special mode for legacy Dashboard widgets (perhaps this mode remains in newer versions—I have not investigated). WebKit also has hacks for applications that embed WebKit on Mac OS X.

The Effects

Here are the main effects of the modes:

Layout

Except in IE, the modes for text/html mainly affect CSS layout and the style system. For example, not inheriting styles into tables is a quirk. In old versions of IE and Opera, the box model changes to the IE 5.5 box model in the Quirks mode. This document does not enumerate all the layout quirks. For a list, please refer to Mozilla’s documentation and the Quirks Mode specification.

In the Almost Standards mode (in browsers that have one and all the current ones do), the height of table cells containing only images is computed differently compared to the Standards mode.

In the XML mode, selectors have different case-sensitivity behavior. Furthermore, special rules for the HTML bodyelement do not apply in older versions of browsers that do not implement the more recent adjustments to the CSS specifications.

Parsing

There are also some quirks that affect HTML and CSS parsing and would cause conforming pages to be misparsed. These quirks are toggled on and off with quirky layout. However, it is important to realize that the Quirks mode vs. Standards mode is predominantly about CSS layout and CSS parsing—not HTML parsing. In browsers that have an HTML5-compliant HTML parser, there is exactly one HTML parsing quirk.

Some people misleadingly refer to the Standards mode as “strict parsing mode”, which is misunderstood to imply that browsers enforced HTML syntax rules and that a browser could be used to assess the correctness of markup. This is notthe case. The browsers do tag soup fix-ups even when the Standards mode layout is in effect. (In the summer of 2000 before Netscape 6 was released, Gecko actually had parser modes that enforced HTML syntax rules and one of these modes was called the “Strict DTD”. These modes were incompatible with existing Web content and were abandoned.)

Another common misconception is related to XHTML parsing. It is often thought using an XHTML doctype gains different parsing. It does not. XHTML documents served as text/html are parsed using the same parser that is used for HTML. As far as browsers are concerned, XHTML served as text/html is just “tag soup with croutons” (an extra slash here and there). Only documents served using an XML content type (e.g. application/xhtml+xml or application/xml) trigger the XML mode for parsing in which case the parser is totally different from the HTML parser.

Scripting

Although the Quirks mode is primarily about CSS, there are some scripting quirks as well. Until Firefox 14, the HTML idattribute didn’t establish object references from the global scripting scope in the Standards and Almost Standards modes. In Firefox, document.all is partially available in the Quirks mode but not in the other modes. The effects on scripting are more dramatic in IE when falling into a mode that emulates an old version of IE.

In the XML mode, some DOM APIs behave differently, because the DOM API behavior for XML is defined to be incompatible with the HTML behavior. With hindsight, this is quite unfortunate.

Doctype Sniffing (aka. Doctype Switching)

Browsers use doctype sniffing in order to decide the engine mode for text/html documents. This means that the mode is picked based on the document type declaration (or the lack thereof) at the beginning of an HTML document. (This does not apply to documents served with an XML content type.)

A document type declaration (doctype) is a syntactic artifact of SGML—a legacy markup framework that HTML prior to HTML5 was purportedly defined in terms of. In the HTML 4.01 specification, the document type declaration is said to communicate HTML version information. Despite the name “document type declaration” and despite what the HTML 4.01 specification says about “version information”, the document type declaration is not an appropriate means for classifying SGML or XML documents as documents of a particular type even though it seems it was supposed to be (hence the name). (More on this in the addendum.)

Neither the HTML 4.01 specification nor ISO 8879 (SGML) says anything about using the document type declaration as an engine mode switch. Doctype sniffing is based on the observation that at the time doctype sniffing was devised the vast majority of quirky documents either didn’t have a document type declaration or they referenced an old DTD. HTML5 acknowledges this reality and defines the doctype in text/html as a mode switch only.

typical pre-HTML5 document type declaration contains (separated by white space) the string “<!DOCTYPE”, the generic identifier of the root element (“html”), the string “PUBLIC”, a public identifier of a DTD in quotes, possibly a system identifier (an URL) of the same DTD and the character “>”. HTML5 simplies the doctype to “<!DOCTYPE html>”. The document type declaration is placed in the document before the start tag of the root element.

Choosing a Doctype

text/html

Here are simple guidelines for choosing a doctype for a new text/html document:

Standards mode, cutting edge validation

<!DOCTYPE html>

This is what you should use. With this doctype, you can validate new features such as <video><canvas> and ARIA. Please be sure to test your page in the latest versions of the top browsers.

Standards mode, legacy validation target

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">

This doctype also triggers the Standards mode, but lets you stick to less precise legacy validation that doesn’t know about new features in case your organization has silly policies that require targeting legacy validation. But you really should be using <!DOCTYPE html> and get the policies of your organization revised.

You’d like to use the Standards mode, but you use sliced images in table layouts and don’t want to fix them

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">

This gives you the Almost Standards mode. Please note that your layouts based on sliced images in tables are likely to break if you later move to HTML5 (and, hence, the full Standards mode), so it’s better to make your designs Standards mode-compatible right now.

You willfully want the Quirks mode

No doctype.

Please don’t do this. Willfully designing for the Quirks mode will come and haunt you, your coworkers or your successors in the future.

If you frustrated by the differences between old IE versions and still need to support them due to client requirements, it is better to apply specific hacks for legacy versions using conditional comments than seek commonality in the Quirks mode.

I am not recommending any of the XHTML doctypes, because serving XHTML as text/html is considered harmful. If you choose to use an XHTML doctype anyway, please note that the XML declaration makes IE 6 (but not IE 7!) trigger the Quirks mode.

application/xhtml+xml

The simple guideline for application/xhtml+xml is not to use a doctype at all. This way the page cannot be “strictly conforming” XHTML 1.0, but that does not matter. (Please see the Addendum below.)

IE8, IE9 and IE10 Complications

It was announced on A List Apart that IE8 would use a meta element-based mode switch in addition to doctype being a factor in the mode choice. (See commentary by Ian HicksonDavid BaronDavid Baron againRobert O’Callahan andMaciej Stachowiak.)

IE8 has four modes: IE 5.5 quirks mode, IE 7 standards mode, IE 8 almost standards mode and IE 8 standards mode. IE9 has seven modes: IE 5.5 quirks mode, IE 7 standards mode, IE 8 almost standards mode, IE 8 standards mode, IE 9 almost standards mode, IE 9 standards mode and IE 9 XML mode. IE10 has eleven modes: IE 5.5 quirks mode, IE 7 standards mode, IE 8 almost standards mode, IE 8 standards mode, IE 9 almost standards mode, IE 9 standards mode, IE 9 XML mode, IE 10 quirks mode, IE 10 almost standards mode, IE 10 standards mode and IE 10 XML mode. The choice of mode depends on data from various sources: doctype, a meta element, an HTTP header, periodically downloaded data from Microsoft, the intranet zone, settings made by the user, settings made by an intranet administrator, the mode of the frame parent if any and a UI button togglable by the user. (With other apps that embed the engine, the mode also depends on the embedding application.)

The lucky thing is that IE8 and IE9 use doctype sniffing roughly like other browsers and IE10 uses doctype sniffing exactly like other browsers if all the following points are true:

  • There is no X-UA-Compatible HTTP header set by the author.
  • There is no X-UA-Compatible meta tag set by the author.
  • Microsoft has not placed the domain name of the site on a blacklist.
  • An intranet admin has not placed the site on a blacklist.
  • The user has not pressed the Compatibility View button (or otherwise added the domain to a user-specific blacklist). (Metro IE10 does not have this UI, but the UI in desktop IE10 affects the behavior in the Metro mode also.)
  • The site is not in the intranet zone.
  • The user has not chosen to display all sites as in IE7.
  • The page is not framed by a Compatibility Mode page.

For the points other than the two X-UA-Compatible cases, IE8 and IE9 perform doctype sniffing like IE7. The IE7 emulation is called Compatibility View.

In the X-UA-Compatible cases, IE8 and IE9 behave radically differently from other browsers. For the behavior of IE8, please see an appendix on this page or a flowchart available in PDF and PNG formats. (Contrast with the chart for other browsers as PDF.) There is also a unified chart of IE 5.5 through 9 (potentially with Chrome Frame) modes as PDF. (I intend to make an IE9-only view of this chart later.)

Unfortunately, without an X-UA-Compatible HTTP header or meta tag, IE8 and IE9 let the user accidentally drop your page from their most standards mode to the IE7 mode that emulates the standards mode of IE7 even if you used a proper doctype. Worse, an intranet admin may do this. Also, Microsoft may have blacklisted the entire domain you use (e.g. mit.edu!).

To counter these effects, a doctype isn’t enough and you need an X-UA-Compatible HTTP header or meta tag.

Here are simple guidelines for choosing an X-UA-Compatible HTTP header or meta tag for a new text/htmldocument that already has a doctype that triggers the standards mode or almost standards mode in other browsers:

Your domain is not on Microsoft’s blacklist and you care more about not having to have browser-specific cruft than about making sure users can’t regress the rendering to IE7 behavior

You don’t need to include an X-UA-Compatible HTTP header or meta tag.

Your domain is on Microsoft’s blacklist, your domain (like iki.fi!) has other authors whose broken sites may induce users to enable Compatibility View for the whole domain, you are concerned about Google or Digg framing your site or you want to make sure users cannot enable the Compatibility View

Include either the following meta element (which in invalid in HTML5) on your page <meta http-equiv="X-UA-Compatible" content="IE=Edge"> (before any script elements!) or set the following HTTP header on your page:X-UA-Compatible: IE=Edge

Your site worked in IE7 but breaks in IE8 or IE9

First, include either the following meta element (which in invalid in HTML5) on your page <meta http-equiv="X-UA-Compatible" content="IE=EmulateIE7"> (before any script elements!) or set the following HTTP header on your page: X-UA-Compatible: IE=EmulateIE7

Then fix your site not to rely on non-standard IE7 behaviors and migrate to IE=Edge.

Your site worked in IE8 but breaks in IE9

First, include either the following meta element (which in invalid in HTML5) on your page <meta http-equiv="X-UA-Compatible" content="IE=EmulateIE8"> (before any script elements!) or set the following HTTP header on your page: X-UA-Compatible: IE=EmulateIE8

Then fix your site not to rely on non-standard IE8 behaviors and migrate to IE=Edge.

Your site worked in IE9 but breaks in IE10

First, include either the following meta element (which in invalid in HTML5) on your page <meta http-equiv="X-UA-Compatible" content="IE=EmulateIE9"> (before any script elements!) or set the following HTTP header on your page: X-UA-Compatible: IE=EmulateIE9

Then fix your site not to rely on non-standard IE8 behaviors and migrate to IE=Edge.

Google Chrome Frame Complications

Google Chrome Frame is a combination of a browser extension and browser plug-in for IE 6, 7, 8 and 9 that adds the engine of Google Chrome into the user interface shell of IE using the networking stack that IE uses. After installation, IE behaves normally by default. However, Web pages can opt to invoke the engine of Chrome instead of the engine of IE using an X-UA-Compatible HTTP header or meta tag.

Specifying chrome=1 in X-UA-Compatible invokes Chrome Frame in any supported version of IE if Chrome Frame is installed. Specifying chrome=IE6 activates Chrome Frame in IE6 only, specifying chrome=IE7 activates Chrome Frame only in IE7 and IE6, and chrome=IE8 activates Chrome Frame only in IE8 and lower.

The directive for activating Chrome Frame can be combined with the directives for controlling the engine of IE (in case Chrome Frame is not installed) by separating them with a comma or a semicolon: <meta http-equiv="X-UA-Compatible" content="IE=Edge,chrome=IE8">.

Once the Chrome Frame has been activated for a page, one of the four modes (Standards, Almost Standards, Quirks and XML) of Chrome is chosen as in normal Chrome.

There are a couple of important reasons against using Chrome Frame:

  • Chrome Frame lacks IE’s accessibility support. When Chrome Frame is activated, the content area in IE becomes an accessibility black hole. That is, screen readers and Windows Speech Recognition don’t work with Chrome Frame.
  • Making your site tell users that they should install Chrome Frame perpetuates the security anti-pattern of sites telling users that they should let someone install a privileged native-code plug-in on their computer in order to use a site.

Links to Related Pages


Addendum: A Plea to Implementors and Spec Writers Working with XML

Please don’t bring doctype sniffing to XML.

Doctype sniffing is a tag soup solution to a tag soup problem. Doctype sniffing was devised after the HTML 4 and CSS2 specs had been written as a heuristic way to distinguish legacy documents from documents whose authors might expect conforming behavior.

Sometimes it is suggested that doctype sniffing be used on the XML side as well for dispatching to different handlers, for recognizing the vocabulary in use, or for activating features. This is a bad idea. Dispatching and vocabulary recognition should be based on namespaces and feature activation should be based on explicit processing instructions or elements.

The whole concept of well-formedness was introduced to allow DTDless parsing of XML and, by extension, doctypeless documents. In formal terms, if two XML documents have the same canonical form and an app treats them differently (and the difference is not due to opting not to process external entities), chances are the app is broken. In practical terms, if two XML documents cause the same content to be reported (qnames ignored) to SAX2 ContentHandler and an app treats the documents differently, chances are the app is broken. Considering that as a Web author you cannot trust that everyone parsing your pages uses an XML processor that resolves external entities (even if some browsers appear to do so because they map certain public ids to an abridged DTD for entity definitions), inserting a doctype in XML intended for the Web is mostly pointless and often done out of a cargo cultish habit. (You can still validate against a DTD using the DTD override feature of the W3C Validator, although the W3C Validator will say that the result is only tentatively valid. Or better yet, you can use RELAX NG validation, which does not pollute the document with schema references.) Requiring a doctype only for sniffing would be silly, even though that is the situation with HTML in practice.

Moreover, when a lower-level spec defines two things that are equivalent, a higher-level spec should not try to give different meanings to the two things. Consider <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">. If the public identifier is removed, the same DTD is still designated and, therefore, the doctype <!DOCTYPE html SYSTEM "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> means the same as the previous doctype. Should they be sniffed differently? The idea can be carried further. Suppose the DTD is copied to example.com and named foobar.dtd: <!DOCTYPE html SYSTEM "http://example.com/foobar.dtd">. How could that one be sniffed? The meaning is the same. The whole DTD could even be pasted inline!

To put it another way, if you have #include "foo.h", you should not bind any black magic to the name foo.h, because it should be permissible to paste the contents of foo.h inline or copy the contents of foo.h to bar.h and say#include "bar.h".

The reason I don’t bother making the same argument with HTML and SGML is that Web browsers don’t use real SGML parsers for parsing HTML, so I don’t think it is useful to pretend that SGML is being dealt with. However, if you are not convinced yet, please see W. Eliot Kimber’s comp.text.sgml post about the matter.

Appendix: Handling of Some Doctypes in text/html

In the following table, Quirks Mode, Standards Mode and Almost Standards Mode are denoted by Q, S and A, respectively. When a browser only has two modes, the Standards Mode is marked as “S”, if the line height in table cells works as in Mozilla’s Standards Mode, and as “A”, if the line height in table cells works as in Mozilla’s Almost Standards Mode.

Please note that XHTML served using an XML content type is rendered in the XML mode.

The purpose of this table is not to suggest that all the doctypes listed in the table are reasonable choices for new pages. The purpose of this table is to show what data I am basing my recommendations on.

The following shorthand notation is used in the column headers:

NS6
Mozilla 0.6…0.9.4 and Netscape 6.0…6.2.3
Old Moz
Mozilla 0.9.5 through 1.1 alpha and Mozilla 1.0
Moz & Safari & Opera 10 & IE10 & HTML5
Mozilla 1.0.1, Mozilla 1.1 beta and later, Firefox, Netscape 7 and later, Safari 0.9 and later, Opera 10 and later, Chrome, Konqueror 3.5, IE10, the HTML5 specified behavior
Opera 9.0
Opera 9.0…9.20
IE 8, IE 9 & Opera 9.5
IE 8 or IE 9 by default when there is no X-UA-Compatible override nor a Compatibility View override (“A” means the IE8 Almost Standards mode for IE8 and IE9 Almost Standards mode for IE9), Opera 7.5…8.54 and 9.5…9.6
IE 7 & Opera 7.10
Windows IE 7, IE 8 with Compatibility View enabled but without X-UA-Compatible override (in this case “A” means the IE7 mode) and Opera 7.10…7.23
IE 6 & Opera 7.0
Windows IE 6 and Opera 7.0…7.03
Mac IE 5
Mac IE 5.0…5.2.3
Konq 3.2
Konqueror 3.2.2…3.3 (possibly also 3.1…3.2.1; I have not been able to confirm)
Doctype NS6 Old Moz Moz &
Safari &
Opera 10
&
IE10
& HTML5
Opera 9.0 IE 8, IE 9 & Opera 9.5 IE 7 & Opera 7.10 IE 6 & Opera 7.0 Mac IE 5 Konq 3.2
None Q Q Q Q Q Q Q Q Q
<!DOCTYPE html> Q S S S S A A A  
<!DOCTYPE html SYSTEM "about:legacy-compat"> ? ? ? ? ? ? ? ?  
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN"> Q Q Q Q Q Q Q Q Q
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN"> S S S S S A A A A
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"> S S S S S A A Q A
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/html4/strict.dtd"> S S S S S A A A A
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"> S S S S S A A A A
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> Q Q Q Q Q Q Q Q Q
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> Q Q Q Q Q Q Q Q Q
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> S S A A A A A A Q
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/1999/REC-html401-19991224/loose.dtd"> Q S A A A A A A Q
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> Q Q Q Q A A A A Q
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd"> S S S S S A A A A
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML Basic 1.0//EN" "http://www.w3.org/TR/xhtml-basic/xhtml-basic10.dtd"> S S S S S A A A A
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> S S S S S A A A A
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> S S A A A A A A Q
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
S S S S S A Q A Q
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML Basic 1.0//EN" "http://www.w3.org/TR/xhtml-basic/xhtml-basic10.dtd">
S S S S S A Q A Q
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
S S S S S A Q A Q
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
S S A A A A Q A Q
<!DOCTYPE HTML PUBLIC "ISO/IEC 15445:2000//DTD HTML//EN"> Q S S Q Q Q Q Q Q
<!DOCTYPE HTML PUBLIC "ISO/IEC 15445:2000//DTD HyperText Markup Language//EN"> Q S S S S A A A Q
<!DOCTYPE HTML PUBLIC "ISO/IEC 15445:1999//DTD HTML//EN"> S S S Q Q Q Q Q Q
<!DOCTYPE HTML PUBLIC "ISO/IEC 15445:1999//DTD HyperText Markup Language//EN"> S S S S S A A A Q

Historical Notes

Mozilla’s doctype sniffing code has changed substantially in October 2000, in September 2001 and in June 2002. This document describes the situation with Mozilla builds made available at ftp.mozilla.org on 2000-10-19 and later (and with Netscape 6.x). This document does not address the way doctype sniffing worked in Mozilla M18 (and Netscape 6.0 PR3). Safari’s doctype sniffing code has also changed substantially since the first public beta. This document does not cover the behavior of versions earlier than v73 aka. 0.9.

Konqueror’s doctype sniffing code prior to version 3.5 appears to come from a very early version of Safari. Konqueror now matches Safari whose doctype sniffing code comes from Mozilla.

As can be seen from the table, Opera’s doctype sniffing has gradually moved from being IE-like to towards being Mozilla-like, although Opera 9.5 and 9.6 regressed on the way. At the same time, the layout behavior of Opera’s Quirks mode has shifted from imitating the Quirks mode of IE 6 towards the Quirks mode of Mozilla.

Appendix: IE8’s Mode Selection

Start: Go to “X-UA-Compatible meta?”.

X-UA-Compatible meta?
IE=7: Use IE7 Standards.
IE=EmulateIE7: Go to “Quirky or No Doctype? (Compatibility Mode)”.
IE=IE8 or IE=IE7 or IE=a or IE=EmulateIE8 or absent or has script first: Go to “X-UA-Compatible HTTP Header?”.
IE=8 or IE=Edge or IE=99 or IE=9.9: Go to “Almost Standards Doctype?”.
IE=5: Use Quirks (IE 5.5).
X-UA-Compatible HTTP Header?
IE=7: Use IE7 Standards.
IE=EmulateIE7: Go to “Quirky or No Doctype? (Compatibility Mode)”.
IE=IE8 or IE=IE7 or IE=a or IE=EmulateIE8 or absent: Go to “Display All Web Sites… Pref Set?”.
IE=8 or IE=Edge or IE=99 or IE=9.9: Go to “Almost Standards Doctype?”.
IE=5: Use Quirks (IE 5.5).
Quirky or No Doctype? (Compatibility Mode)
Yes: Use Quirks (IE 5.5).
No: Use IE7 Standards.
Display All Web Sites… Pref Set?
Yes: Go to “Quirky or No Doctype? (Compatibility Mode)”.
No: Go to “Display Intranet Sites… Pref Set?”.
Display Intranet Sites… Pref Set?
Yes: Go to “Is the site in the Intranet Zone?”.
No: Go to “Domain on MS-Maintained List?”.
Is the Site in Intranet Zone?
Yes: Go to “Quirky or No Doctype? (Compatibility Mode)”.
No: Go to “Domain on MS-Maintained List?”.
Domain on MS-Maintained List?
Yes: Go to “Quirky or No Doctype? (Compatibility Mode)”.
No: Go to “Framed by Compatibility Mode page?”.
Framed by Compatibility Mode page?
Yes: Go to “Quirky or No Doctype? (Compatibility Mode)”.
No: Go to “Compatibility Mode Button Pressed?”.
Compatibility Mode Button Pressed?
Yes: Go to “Quirky or No Doctype? (Compatibility Mode)”.
No: Go to “Quirky or No Doctype? (IE8)”.
Quirky or No Doctype? (IE8)
Yes: Use Quirks (IE 5.5).
No: Go to “Almost Standards Doctype?”.
Almost Standards Doctype?
Yes: Use IE8 Almost Standards.
No: Use IE8 Standards.

The steps are available as a flowchart in PDF and PNG formats.

Acknowledgments

Thanks to Simon Pieters, Lachlan Hunt and Anne van Kesteren for their help with correcting the mode table for various Opera versions and for their comments. Thanks to Simon Pieters for the text alternative for the IE8 flowchart.

Activating Browser Modes with Doctype的更多相关文章

  1. 前端翻译:Activating Browser Modes with Doctype

    一.前言 原本备份: http://www.cnblogs.com/fsjohnhuang/p/3830623.html 由于本人英语能力有限,译本内容难免有误,望各位指正! 本译文不含附录部分,请知 ...

  2. JS魔法堂:doctype我们应该了解的基础知识

    一.前言 什么是doctype?其实我们一直使用,却很少停下来看清楚它到底是什么,对网页有什么作用.本篇将和大家一起探讨那个默默无闻的doctype吧! 二.什么是doctype doctype或DT ...

  3. doctype(文档类型)的作用是什么?转载

    <!DOCTYPE> 声明位于文档中的最前面的位置,处于 <html> 标签之前.此标签可告知浏览器文档使用哪种 HTML 或 XHTML 规范. Document Type ...

  4. DOCTYPE 与浏览器模式分析

    DOCTYPE 的诞生 DOCTYPE,或者称为 Document Type Declaration(文档类型声明,缩写 DTD).通常情况下,DOCTYPE 位于一个 HTML 文档的最前面的位置, ...

  5. HTML文档模式与盒模型

    HTML文档根据文档顶部的doctype声明来决定渲染模式,有标准模式(Standards Mode)与怪异模式(Quirks mode,或叫做混杂模式)两种模式. IE5及以前默认总是表现为怪异模式 ...

  6. IE浏览器兼容性模式

    最近支持公司的一个内部业务管理系统,系统是基于jQuery来实现:用了2年的MVVM框架的我转向这个完全使用jQuery框架来开发的系统,真是相当不爽(相信用过MVVM框架的跟我是相同的感受):更为憋 ...

  7. 《CSS Mastery》 读书笔记 (1)

    --本笔记中英混合,专业名词尽量不翻译,免得误解,如果不习惯,就不用往下看了,走好不送. 第一章 基础 人类的好奇心总是促使我们捣鼓,捣鼓是最好做有效的学习CSS的方法 In this chapter ...

  8. selenium docs

    Note to the Reader - Docs Being Revised for Selenium 2.0! Introduction Test Automation for Web Appli ...

  9. ueditor使用小结

    一.简介 ueditor是百度编辑器,官网地址:http://ueditor.baidu.com/website/ 完整的功能演示,可以参考:http://ueditor.baidu.com/webs ...

随机推荐

  1. spring scope="prototype", scope="session"

    转自: http://www.cnblogs.com/JemBai/archive/2010/11/10/1873954.html struts+spring action应配置为scope=&quo ...

  2. IOS6屏幕旋转详解(自动旋转、手动旋转、兼容IOS6之前系统)

    转自 http://blog.csdn.net/zzfsuiye/article/details/8251060 概述: 在iOS6之前的版本中,通常使用 shouldAutorotateToInte ...

  3. ZookeeperNet太难用,写了个RetryHelper来进行配套使用

    普通的zk用法,如下写法: zk.Exists("/aaa", true); zk.Create(...); 但是由于这些API会抛Zookeeper的Exception,比如Co ...

  4. Android TextUtils类介绍

    对于字符串处理Android为我们提供了一个简单实用的TextUtils类,如果处理比较简单的内容不用去思考正则表达式不妨试试这个在android.text.TextUtils的类,主要的功能如下: ...

  5. Kernel Function--核函数收集

    转自 http://www.zhizhihu.com/html/y2010/2292.html Kernel Functions Below is a list of some kernel func ...

  6. 完全图解scrollLeft,scrollWidth,clientWidth,offsetWidth 获取相对途径,滚动图片(网上找的,未经试验,但觉得比较好)

    获取元素的位置属性可以通过 HTMLElement.offsetLeft HTMLElement.offsetTop 但是,这两个属性所储存的数值并不是该元素相对整个浏览器画布的绝对位置,而是相对于其 ...

  7. @Html.DropDownList 设置选中值无效

    有时候在ASP.NET  MVC中用@Html.DropDownList 设置选中值无效,如图: 具体原因说不清,反正只要改个名字就行了!!!,如图:::

  8. ASP.NET中彩票项目中的计算复式投注的注数的方法

    从别人做的项目中抽取出的代码:

  9. 命令行上的narrowing(随着输入逐步减少备选项)工具

    前面在介绍zsh的时候,说过它的补全用来起比bash的Tab补全方便多了,在有多个备选项是你只要用光标键来挑选就是了,而不是全列出来提示你再多输入几个字符.而Emacs的anything / helm ...

  10. List的遍历和删除元素

    package test; import java.util.ArrayList; import java.util.Iterator; import java.util.List; public c ...