Activate the browser mode with doctype

sponsored links
http://dancewithnet.com/2009/06/14/activating-browser-modes-with-doctype/

To address the standard under the Web page creation and 90 under in the late 20th century, the old practice of popular Web page creation, a modern Web browser to achieve a variety of engine models. This article explains what those patterns are and how to trigger them.

Original: Henri Sivonen 's Activating Browser Modes with Doctype 2009.05.19

Document Scope


This article includes a mode switch (mode switching) applies to Firefox and other Gecko-based browser, Safari, Chrome and other browsers based on Webkit, Opera, Konqueror, Mac version of Internet Explorer, Windows version of Internet Explorer and the embedded IE browser device. Avoid referring to the name of the browser engine , replaced the use of the engine's best-known browser name.

This paper introduces the model selection mechanism, rather than recording the exact behavior of each model.

Mode


Here are a variety of modes:

Content type is text / html mode


text / html content of the mode selection depends on the doctype sniffing (doctype sniffing, have been discussed later in this article ). In IE8, the model also depends on other factors. However, IE8's default, which is not provided by Microsoft on the blacklist of non-local area network (non-intranet) sites of the model depends on the document type.

No matter how stressed every browser precise behavior pattern is however different points, even if this paper conducted a unified discussion.

Quirks mode (Quirks Mode)
Quirks mode, in order to avoid "damage" to those under 90 in the late 20th century, the popular practice of writing the page, the browser in violation of the modern Web format specification. Different browser quirks to achieve a different behavior. Internet Explorer6, 7 and 8, the eccentric mode effectively frozen in IE5.5. Other browsers, quirks mode is the standard model targeting small offset.
If you are writing a new page, you should meet the relevant specifications (especially CSS2.1) and using the standard model.
Standard mode (Standards Mode)
Standard mode, the browser tries to meet the standards of documentation in the specification of the correct handling of the browser to the specified level.
Different browsers follow different stages, so the standard model is not a single target.
HTML5 to this model is called "non-quirks mode (no quirks mode)"
Quasi-standard mode (Almost Standards Mode)
irefox, Safari, Chrome, Opera (starting from 7.5) and IE8 is also a man named "quasi-standard model" mode, which is the traditional practice to achieve the vertical size of a table cell and not strictly follow the CSS2 specification. Mac IE5, Windows IE6 and 7, Opera7.5 previous versions and Konqueror without pre-standard mode, because they at least not in their standard mode to achieve strict compliance with CSS2 specification table cell vertical dimension. In fact, they are closer to the standard mode of Mozilla's pre-standard mode instead of Mozilla's standard mode.
This model HTML5 shouted "limited quirks mode (limited quirks mode)".
IE7 mode
IE8 has a mode is to freeze a copy of IE7 standard mode. Other browsers do not like this model, and the model has not been specified HTML5.

Content type is application / xhtml + xml mode (XML mode)


Firefox, Safari, Chrome and Opera in, application / xhtml + xml HTTP content type (not a meta element is not doctype!) Will trigger XML mode. In XML mode, the browser attempts to standardize on XML documents in the correct treatment to the development of the browser level.

IE6, 7 and 8 do not support application / xhtml + xml, Mac IE5 also do so.

The Nokia S60 WebKit-based browser, application / xhtml + xml HTTP content type can not trigger XML mode, because in the mobile walled garden (mobile walled gardens) of concern is the compatibility of non-standard content. ( old-style "mobile browser" can not use a real XML parser , because it does not regulate the content has been marked as XML.)

In the absence of fully tested Konqueror, I can not exactly say in the browser, what will happen.

Non-Web model (Non-Web Modes)


Some of the engine model has nothing to do with the Web content. For completeness, they are only being mentioned here. Opera has a WML2.0 mode. Leopard on the old WebKit have Dashboard widgets for the particular model.

Affect


The following are the main impact of these patterns:

Layout


text / html mode is mainly affected CSS layout. For example, the table does not inherit style is eccentric. In some browser quirks mode box model (box model) into IE5.5 the box model. This document does not list all of the layout quirks.

Quasi-standard mode (with this model in your browser), the only picture of the table cell that contains the high and standard mode different.

XML mode, the selectors have different case-sensitive behavior. In addition, for the HTML body element of the specific rules can not apply changes that do not achieve the latest CSS2.1 older browsers.

Resolve


There are also some quirks affect the HTML and CSS in the analysis and would result in standards-compliant page is error analysis. Eccentricity distribution of the decision whether to open these quirks. In any case, about quirks mode and standard mode in the CSS layout and analysis (non-HTML parsing) the main similarities and differences is very important.

Some people mistakenly regard the standard model known as "strict parsing mode (strict parsing mode)", its misleading HTML browser to enforce the rules of grammar and marked with the assessment of the correctness of the browser. Not the case. Even when the standard mode of entry into force of the layout, the browser still do label clam (tag soup, http://en.wikipedia.org/wiki/Tag_soup) rectification. (Published in 2000 Netscape6 before, Mozilla does have HTML syntax rules for the enforcement of the analytical model. These models and not compatible with existing Web content be abandoned.)

Another common misconception is about XHTML parsing. Generally considered by using different analytical XHTML doctype. This is not so, the content type is text / html for XHTML documents and HTML documents used by the parser is the same. Concerned about the current browser is the document type to text / html for XHTML is just "spread bread clam small label (tag soup with croutons)" (full of extra slash).

Only when the document using XML document type (for example: application / xhtml + xml or xmapplication /) will trigger the XML model to resolve, when the parser completely different from the HTML parser.

Script


Although the quirks mode is on CSS, but there is something about the script. For example, Firefox's quirks mode, HTML id attribute, as in IE as the establishment of the global script scope of the object reference. IE8 impact on the script more than any other browser noteworthy.

XML model, some of the DOM API has totally different, because XML's DOM API behavior is not compatible with the definition of the behavior of HTML.

doctype sniffing (also called doctype switching)


Modern browsers use doctype sniffing to determine text / html document, the engine model. This means that the choice of model is based on the HTML document, start the document type declaration (or lack of). (This is not suitable for the type of document using the XML document.)

Document type declaration (doctype) is the syntax of SGML forged, SGML is a markup framework old, HTML5 is based on its previous definition of HTML. HTML4.01 specification, the document type declaration describes HTML's version information . Although called the "document type declaration" and HTML 4.01 specification is described on the "version information", the document type declaration does not apply to SGML or XML document is classified as a specific type of document, even if it looks like (because of name) . ( more in the appendix )

HTML4.01 norms and ISO 8879 (SGML) have not said a statement on the use of document type engine mode conversion as anything. doctype sniffing is based on the observation, in the doctype sniffing to be designed, most of the quirks document neither the document type declaration does not refer to the old DTD. HTML5 accept this fact, and defines the text / html in the doctype as the only model.

A typical pre-HTML5 (pre-HTML5) document type declaration contains (separated by white space) "<! DOCTYPE" string, the root element ("html") of common identifier, "PUBLIC" string, in quotation marks in the DTD public identifier, the possibility of the same DTD system identifier (URL) and the character ">." Document type declaration in the document root element start tag.

Select doctype

text / html


The following is to create a new text / html document, how to choose the doctype simple guidelines:

Standard mode, the most cutting-edge verification
<!DOCTYPE html>
If you want to verify , such as <video>, <canvas> and ARIA such new features, then this is right. Note, HTML5 is still effective in changing the definition, make sure that Firefox, Safari, Chrome, Opera9 or Opera10 test image alignment. In Internet Explorer, test image alignment is not enough, in any case make sure that IE8 also tested.
Standard model, a more stable target validation
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
The doctype will trigger standards mode, and 10-year-old HTML4.01 effective definition of stability. Make sure Firefox, Safari, Chrome, Opera9 or Opera10 test image alignment. In Internet Explorer, test image alignment is not enough, in any case make sure that IE8 also tested.
To use the standard mode, but still verify that the form is not recommended layout tags or in the use of slice images and does not want to fix them.
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
It will trigger the pre-standard mode (and old-fashioned Mozilla in full standard mode full Standards mode). Please note that if the later transplanted to HTML5, and based on the slice images using the form to achieve the layout may be destroyed (and the full standard model is also the case).
Deliberately to use the quirks mode
No doctype.
Please do not do so. Deliberately made the design for the quirks mode will haunt you and your colleagues in the future or successor, no one even care about Windows IE6 (Netscape4.x and IE5 have no one care about a). Design for the quirks mode is a bad idea. Believe me.
If you want to still support Windows IE6, it made a special hack to use conditional comments to make other browsers than to degenerate into quirks mode good.

I do not recommend any of the XHTML doctype, because XHTML is used as text / html considered harmful . Anyway, if you choose to use the XHTML doctype, please note that XML declaration will make IE6 (but not IE7!) To trigger quirks mode.

application / xhtml + xml


On the application / xhtml + xml is not a simple guide to using doctype. The mode page is not "strict consensus" of XHMTL1.0, but it is not important. (See the back of Appendix )

IE8 complications


A List Apart has introduced , IE8 will use outside than doctype element model-based meta model transformation as a choice of one of the factors. (See Ian Hickson , David Baron , David Baron again , Robert O'Callahan , and Maciej Stachowiak 's comments.)

IE8 has 4 modes: IE5.5 quirks mode, IE7 standards mode, IE8 Standards mode and IE8 quasi-standard mode. Model selection depends on the data from several areas: doctype, meta element, HTTP headers, regular downloading of data from Microsoft, LAN domain, the user made settings, LAN administrators have done to set the parent frame of the model (if any) and address bar compatibility view button is user initiated. (Embedded in the engine for other applications, pattern also depends on the embedded application.)

Fortunately, if the following conditions, IE8 will be largely the same as other browsers use doctype sniffing:

  • Author did not set X-UA-Compatible HTTP header
  • Author did not set X-UA-Compatible meta tag
  • Microsoft did not place the site in the blacklist of domain names
  • LAN administrator does not put the site onto the blacklist on
  • User does not press the Compatibility View button (Compatibility View button) (or otherwise added to a specific user blacklist)
  • The site is not in the LAN domain
  • The user did not choose to display all the sites in IE7
  • Page did not pass the compatibility mode frame embedded in the page

The addition of two on the X-UA-Compatible in the circumstances, IE8 as IE7, like the implementation of doctype sniffing. IE7 emulation (IE7 emulation) is called compatible with the view.

In the X-UA-Compatible case, IE8's behavior and other browsers are totally different. Want to see this page appendix or PDF and Activate the browser mode with doctype


Flow chart format.

Unfortunately, no X-UA-Compatible in the HTTP header or meta tag, even with the right doctype, IE8 lets users inadvertently make IE8's Standards mode pages dropped from IE7 mode, which is a simulation of IE7 standard mode . Worse, LAN administrators can do. Microsoft could also be used for all your domain name to be blacklisted.

To deal with these effects, doctype is not enough, you need to X-UA-Compatible HTTP header and meta tags.

The following simple guidelines have been doctype against other browsers in standards mode, or trigger a new quasi-standard model text / html document, how to choose the X-UA-Compatible HTTP header or meta tag:

Your domain name is not in Microsoft's blacklist, you are more concerned about the browser is not exclusive of the unpleasant things rather than to ensure that users can not recede back to show the behavior of IE7.
You do not need to include the X-UA-Compatible HTTP header or meta tag.
Your domain blacklisted in Microsoft, because your domain name in the other authors may result in destruction of the site users view the entire domain compatibility is enabled, you are worried about Google or Digg Yong frame embedded in your site, or you want to ensure that users can not use compatible view
First, the back of your page contains meta-elements (which is illegal in HTML5) <meta http-equiv="X-UA-Compatible" content="IE=Edge"> (before any script elements), or set back the HTTP header: X-UA-Compatible: IE = Edge
Your site in IE7, but IE8 in the destruction of the work
First, the back of your page contains meta-elements (which is illegal in HTML5) (before any script elements), or set back the HTTP header: X-UA-Compatible: IE = EmulateIE7, then fix your site IE7 does not rely on non-standard behavior and moved to the IE = Edge.

Related Links

Addendum: The XML implementation and the specification of plea


Please do not doctype sniffing into the XML.

doctype sniffing is signed clam-like solution to the problem of a tag clam. doctype sniffing in HTML4 and CSS2 specification designed after the release of a test method to distinguish it from a document dated the document to meet the expectations of its author may act.

Occasionally it was suggested to use doctype sniffing in the XML to a different treatment schedule, identify vocabulary in use or activate the feature. This is a bad idea. Scheduling and vocabulary recognition should be based on the name space, and feature activation should be based on explicit processing instructions or elements.

Good structure (well-formedness) introduced the whole idea is to allow non-XML, DTD resolution, and promotion of documents without doctype. In formal situations, the two XML documents have the same canonical form and apply a different deal with them (and the difference is not because there is no choice to deal with external entities), the uses might be destroyed. In practice, if two XML documents lead to the same content have been reported (qnames ignored) to the SAX2 content handler to deal with different documents and applications, the application or be destroyed. On the Web can not be taken into account as one would use for additional entities XMLprocessor to resolve their page (even if some browser looks like it did, because they are mapped some public identifier to a full-length definition of entities DTD), insert doctype into XML, is meaningless for the Web and often result in cargo cult (cargo cultish) habits. (You can still use the W3C Validator DTD override function to validate a DTD, although the W3C validator will say the result is only valid for the time being. or better, you can relax NG validation , it will not pollute the model reference document.) To ask the doctype sniffing is stupid, even if it is in the HTML practice solutions.

In addition, when low-level specification defines two things equal, the high level of specification should not try to give them different meanings. Please consider <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">. If you remove the public identifier, still designated the same DTD, so doctype <!DOCTYPE html SYSTEM "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> that and in front of the same doctype. What should be different to sniff them? Further theory. Suppose example.com called foobar.dtd copy to the DTD: <!DOCTYPE html SYSTEM "http://example.com/foobar.dtd">. This is how to sniff? Should be the same thing. Even the DTD can be affixed to the document.

In other words, if there is # include "foo.h", you should not bind to the name foo.h any black magic, as it should be allowed to copy the contents of the document foo.h or copy foo.h to bar.h in and said # include "bar.h".

I do not worry about HTML and SGML structure is due to the same parameters will not use the Web browser a real SGML parser to parse HTML, so I think posing for processing SGML is of no use. In any case, if you do not believe, see W. Eliot Kimber on this article comp.text.sgml

Appendix: text / html in the treatment of some doctype


In the following table, quirks mode, standard mode and quasi-standard, respectively, for the Q, S and A. When the browser only two modes, if the table cell row and Mozilla's standard mode of high performance line, the standard model is marked as "S", if the table cell row height and Mozilla performance of the quasi-standard mode is identical to , is labeled "A".

Please note that use XML to provide services to the XHTML content model in XML mode rendering.

The purpose of this table is not to say all the doctype table are the logical choice for the new page. The purpose of this table is to show my recommendation is based on what kind of data.

The following shorthand notation is used for column headings:

NS6
Mozilla 0.6 ... 0.9.4 and Netscape 6.0 ... 6.2.3
Old Moz
Mozilla 0.9.5 and Mozilla 1.0 to 1.1 alpha
Moz & Safari & Opera 10 & HTML5
Mozilla 1.0.1, Mozilla 1.1 beta and later, Firefox to Netscape 7, Safari 0.9 to the Safari 4.0 beta, Opera 10, Chrome, Konqueror 3.5, HTML5 specified behavior
Opera 9.0
Opera 9.0 ... 9.20
IE 8 & Opera 9.5
No X-UA-Compatible and the default compatibility mode cover IE8 (in the case of "A" means that IE8 pre-standard mode), Opera 7.5 ... 8.54 and 9.5 ... 9.6
IE 7 & Opera 7.10
IE7, compatibility mode with no X-UA-Compatible covered IE8 (this case "A" means that 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 (may also include 3.1 ... 3.2.1; I have yet to be determined)

History


Moziila the doctype sniffing code in October 2000, September 2001 and June 2002 with substantial changes. This document describes the Mozilla (and Netscape 6.x) to establish the state may, see 2000.10.19 at ftp.mozilla.org. This document is not related to Mozilla M18 (and Netscape 6.0 PR3) in the doctype sniffing work. Safari's doctype sniffing code from the first public test version since there are substantial changes. This document does not include more than an earlier version of the V73 is also called the behavior of 0.9.

Konqueror3.5 before the doctype sniffing code seems to come from a very early version of Safari. Konqueror and Safari are now matching the doctype sniffing code from Mozilla.

Can be seen from the table, Opera's doctype sniffing by law from a similar change in IE to Mozilla similar, although Opera9.5 and 9.6 in the back on the road. Meanwhile, Opera Quirks Mode follow the layout of behavior from IE6 quirks mode switch to Mozilla's Quirks Mode.

Appendix: IE8 mode selection

Start: Go to "X-UA-Compatible meta?"
X-UA-Compatible meta?
IE = 7: use the IE7 Standards
IE = EmulateIE7: enter "quirks or no doctype? (Compatibility Mode)"
IE = IE8 or IE = IE7 or IE = a or IE = EmulateIE8 or not, or first appeared script: enter "X-UA-Compatible HTTP header?"
IE = 8 or IE = Edge or IE = 99, or IE = 9.9: enter the "quasi-standard model?"
IE = 5: use the quirks mode (IE5.5)
X-UA-Compatible HTTP header?
IE = 7: use the IE7 Standards mode
IE = EmulateIE7: enter "quirks or no doctype? (Compatibility Mode)"
IE = IE8 or IE = IE7 or IE = a or IE = EmulateIE8 or not: Go to "Show all sites ... pre-set?"
IE = 8 or IE = Edge or IE = 99, or IE = 9.9: enter the "quasi-standard model?"
IE = 5: use the quirks mode (IE5.5)
Quirks mode or no doctype? (Compatibility mode)
Are: use quirks mode (IE5.5)
No: Using IE7 standard mode
Show all sites ... pre-set?
Is: to enter "quirks mode or no doctype? (Compatibility Mode)"
No: Go to "display the LAN site ... pre-set?"
Show LAN site ... pre-set?
Is: to enter "the site is located in the LAN domain?"
No: Go to "domain name on the list maintained at Microsoft?"
Domain name on the list maintained at Microsoft?
Is: to enter "quirks mode or no doctype? (Compatibility Mode)"
No: Go to "compatibility mode page is embedded with a Frame?"
Compatibility mode page is embedded with a Frame?
Is: to enter "quirks mode or no doctype? (Compatibility Mode)"
No: Go to "compatibility mode by pressing the button?"
Compatibility mode by pressing the button?
Is: to enter "quirks mode or no doctype? (Compatibility Mode)"
No: Go to "quirks mode or no doctype? (IE8)"
Quirks mode or no doctype? (IE8)
Are: access to "use quirks mode (IE5.5)"
No: Go to the "quasi-standard model?"
Quasi-standard model?
Are: quasi-standard mode using IE8
No: use IE8 standards mode

These steps are available through PDF and Activate the browser mode with doctype


See flow chart format.

  • del.icio.us
  • StumbleUpon
  • Digg
  • TwitThis
  • Mixx
  • Technorati
  • Facebook
  • NewsVine
  • Reddit
  • Google
  • LinkedIn
  • YahooMyWeb

Related Posts of Activate the browser mode with doctype

  • Design patterns seen by the (strategic model strategy)

    java design patterns, wrote Strategy pattern in a given input conditions, to achieve a target of the plan or program. Strategies and algorithms are similar; algorithm is a defined process, it can provide a set of input produces an output. The strateg ...

  • Grinder data collection

    What is a Grinder? Grinder is a Java TM load testing framework to support distributed testing, and is open source. Grinder on the latest news, downloads, and other conditions available from the following Web sites: SourceForge.net . The Grinder proce ...

  • 23 kinds of design patterns Experience

    Factory (factory mode): the object generating process of the closed-control client does not care about the object generating process. Factories for you to complete these trivial matters. Requirements are often different types of production according ...

  • What is B / S structure, B / S structure, what advantages (switched from Baidu Wikipedia)

    Small knowledge: What is B / S structure, B / S structure, what advantages (switched from Baidu Wikipedia) B / S structure (Browser / Server structure) structure, the browser and the server architecture. It is with the rise of Internet technology on ...

  • Others reproduced the article on the servletContext and servletConfig

    Transfer from: http://kuru.javaeye.com/blog/147363 For the web container is, ServletContext interface defines a servlet environment, object, this object defines a servlet in the servlet engine's view. By using this object, servlet can log events, ...

  • SSH + AJAX project link "Internet Explorer can not open the site, has ceased to operate" to solve the problem

    Government has recently done a project, SSH + AJAX, pre is going smoothly and when the final integration test found there some link "Internet Explorer can not open the site, the operation has been terminated", that is not optimized, so re-o ...

  • Performance tests of the impact of bandwidth

    In the past two days have been tuning to do after the test server, the details on page one of the pressure test, the test results for 110TPS, for this we are extremely dissatisfied with the results, and then in a number of different module under test ...

  • Standardize procedures for coding JavaScript

    This is a set of procedures applicable to JavaScript coding norms. It is based on Sun's Java program code norms. However, a drastic changes, because JavaScript is not Java. Long-term value of the software directly from the quality of its encoding. In

  • YUI Grids CSS 003 - Getting Started tutorial

    First, we propose using the following this! DOCTYPE to call the browser's standard browser mode (if the browser has a variety of browser mode). Want to use YUI Grids CSS, first of all you need to use the link in the page tag contains the followin ...

  • Talk about the "design mode"

    Now more and more frameworks; model appears to reduce the use of the opportunity, then mean that we do not have to grasp the mode of the case? In fact, in order to study the actual training model mode of thinking, modes of thinking help to understand ...

blog comments powered by Disqus
Recent
Recent Entries
Tag Cloud
Random Entries