Quirks mode and Standard mode

Source: Internet
Author: User

Due to historical reasons, each browser has different rendering on the page, and even the same browser in different versions, the page rendering is not the same. Before the introduction of the world standard, the browser has no uniform specification on the rendering of the page, resulting in a difference (Quirks mode or compatibility mode); Due to the introduction of the world standard, browser rendering page has a unified standard ( Csscompat or Strict mode is also called Standars mode), which is the simplest difference between the two.
After the introduction of the standard, the browser began to adopt the new standards, but there is a problem is how to ensure that the old page can continue to browse, before the standard comes out, many pages are based on the old rendering method, if used by the standard to render, will cause the page to show an exception. In order to maintain the compatibility of browser rendering, so that the previous page can browse normally, the browser retains the old rendering methods (such as: Microsoft's IE). In this way, Quircks mode and standars mode are generated on the browser rendering, and there is a common browser for both rendering methods.

Firefox has been working in standard mode, but IE (6,7,8) standard mode and strange mode is very different, mainly reflected in the box model interpretation, this is very important, the following focus on this. So what kind of mode does the browser use to render? This leads to the DTD, which is the head declaration of the Web page, and the browser uses the corresponding rendering pattern by identifying the DTD:
1. The browser to make the old page work, but this part of the page is not DOCTYPE declaration, so the browser does not doctype the declaration of the page using Quirks mode parsing.
2. For Web pages that have a DOCTYPE statement, what kind of browser is the mode of resolution, here is a detailed list to refer to: Http://hsivonen.iki.fi/doctype.
3. For Web pages with DOCTYPE claims, here are a few simple rules that can be used to determine: For DOCTYPE statements that are not recognized by browsers, the browser uses strict mode parsing.
4. In the DOCTYPE declaration, when no DTD declaration is used or a DTD declaration with HTML4 (excluding HTML4) is used, all basic browsers are rendered using quirks mode, others using strict mode parsing.
5. It can be said that, in the existing DOCTYPE statement of the Web page, the vast majority of the use of strict mode to parse.
6. In IE6, if there is an XML declaration before the DOCTYPE declaration (for example: <?xml version= "1.0″encoding=" iso-8859-1″?>), quirks mode is used to parse it. This rule has been removed from the IE7.
How to set to Weird mode:

Method One: Add <! in the page item section DOCTYPE HTML PUBLIC "-//w3c//dtd HTML 4.01 transitional//en" >
Method Two: Nothing is added.
How to set to Standard mode:

Add any of the following: HTML4 offers three types of doctype to choose from:
<! DOCTYPE HTML PUBLIC "-//w3c//dtd HTML 4.01 transitional//en" "HTTP://WWW.W3.ORG/TR/HTML4/LOOSE.DTD" >

<! DOCTYPE HTML PUBLIC "-//w3c//dtd HTML 4.01//en" "HTTP://WWW.W3.ORG/TR/HTML4/STRICT.DTD" >

<! DOCTYPE HTML PUBLIC "-//w3c//dtd HTML 4.01 frameset//en" "HTTP://WWW.W3.ORG/TR/HTML4/FRAMESET.DTD" >

XHTML1.0 offers three types of doctype to choose from:

(1) Transition type (transitional)
<! DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1.0 transitional//en" "Http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd ">

(2) strict type (Strict)
<! DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1.0 strict//en" "Http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd" >

(3) frame type (Frameset)
<! DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1.0 frameset//en" "Http://www.w3.org/TR/xhtml1/DTD/xhtml1-frameset.dtd" >

How to determine whether it is a standard mode or a weird mode:

Method One: Execute the following code
alert (Window.top.document.compatMode);
Backcompat means weird mode.
Css1compat indicates standard mode

Method Two: jquery provides us with the following methods:
Alert ($.boxmodel)
Alert ($.support.boxmodel)

The so-called standard mode refers to the browser in accordance with the standards of the code to parse the execution, the weird mode is to use the browser's own way to parse the execution code, because the different browser parsing executes differently, so we call it a strange mode. whether the browser resolves using standard mode or weird mode, directly related to the DTD declaration in your Web page, the DTD declaration defines the type of standard document (standard schema Parsing) document type, causes the browser to load the Web page and display it in the appropriate way, ignoring the DTD declaration, which will put the Web page into a weird mode (quirks mode).

Quirks mode and Standard mode

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.