Doctype strict and promiscuous modes-how do you trigger these two patterns to differentiate between them?

Source: Internet
Author: User

Doctype: Document type, which is located at the front of the document, before the label. If you want to create a standard-compliant page, an essential key component is the DOCTYPE statement. Determine the correct doctype,xhtml inside the logo and CSS to work properly (that is, it will be very responsible to tell the browser how to explain your tag and the CSS you write). Since it is a statement, its responsibility is to tell the browser which HTML or XHTML specification to use for the document. The key to getting the correct DOCTYPE statement is to have the DTD correspond to the standards that the document follows. For example, if the document follows the XHTML 1.0 Strict, then the DOCTYPE declaration of the document should be the appropriate DTD, if the DOCTYPE declaration specifies an XHTML DTD, but the document still contains HTML markup that is inappropriate. Similarly, if the document contains an XHTML 1.0 strict tag, it is not appropriate for the DOCTYPE declaration to be specified as an HTML DTD.

  First, choose what kind of doctype?

There are 3 DTD declarations in XHTML 1.0 that can be selected, transitional (transitional), Strict (Strict), and Framework (Frameset). Let's go through the following separate sections:

1, Transition: a requirement is not very strict, allow the HTML 4.01 in the use of the identity (conforming to the XHTML syntax Standard), the transition DTD is written as follows:

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


2, strict: A strict DTD, does not allow the use of any performance layer of the identity and attributes, strict DTD written as follows:

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

  
3. Framework: A DTD used specifically for frame pages, when the page contains frame elements, this DTD should be used as follows:

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


PS: Using a strict DTD to make a page is certainly the best way to do it, but for web designers who don't yet have a deeper understanding of web standards, it's more appropriate to use a staging DTD because it also allows for the use of the presentation layer's identity, elements, and attributes, which are more suitable for most web page creators (possibilities, of course).


second, what is the standard mode and promiscuous mode?

The different document modes mainly affect the rendering of CSS content, especially the browser's parsing of the box model, but in some cases it will also affect the execution of JavaScript interpretation.
1, the document mode currently has four kinds:

Promiscuous modes (quirks mode)
Make IE behave the same as IE5 (including non-standard features)
Standard modes (Standards mode)
Let IE behave more closely to standard behavior
Quasi-standard Model (almost standards mode)
Many of the browser features in this mode are standards-compliant, and the non-standard areas are mainly when dealing with picture gaps (the problem is most noticeable when using images in tables).
Super Standard mode:
A new document pattern introduced by IE8, the Super document mode allows IE to interpret web content in the most standard way in all its versions.
Ps:
Overall, promiscuous mode makes IE like IE5, the standard mode uses the IE7 rendering engine, while the Super Standard mode is the default document mode of IE8.

(another article about promiscuous mode interpretation:

What is promiscuous mode?

Promiscuous mode is a relatively loose backward-compatible mode. Promiscuous mode typically simulates the behavior of older browsers to prevent old sites from working.

Why is there a promiscuous pattern?

When Netscape4, the early browser of Netscape and IE4 (the early browser of Microsoft), implemented the CSS mechanism, it did not follow the standards presented by the Internet company. Netscape4 provided poor support, while IE4, though close to the standard, still failed to fully correct the standard of support. Although IE 5 fixes many of the IE4 problems (bugs), it still continues with other failures in the CSS implementation (mainly the box model). In order to ensure that their website is displayed correctly on each browser, Web developers have to use CSS according to the specifications of each browser, so the CSS implementations of most Web sites do not conform to the standard. However, as standard consistency becomes more important, browser developers have to face a difficult choice: Gradually following the standard is the way forward. But changing the existing CSS, completely to follow the standard, will make many old sites more or less destroyed, if the browser suddenly in the correct way to parse the existing CSS, the old site display will inevitably be affected. Therefore, all browsers need to provide two modes: Promiscuous mode service with legacy rules, while strict mode serves standard Rules

  third, how to trigger them ?

Depending on whether the DOCTYPE exists and what DTD is used to trigger its different patterns. If the DOCTYPE does not exist or its form is incorrect then the default is promiscuous mode. If the XHTMLL document contains the full DOCTYPE, it is generally rendered in standard mode.
2. How to trigger the document mode:

Trigger Promiscuous mode:
If the document type declaration is not found at the beginning of the document, all browsers turn on promiscuous mode by default. But using promiscuous mode is not a recommended practice, because different browsers behave differently in this mode, and if you don't use some hack technology, cross-browser behavior is simply not consistent.
Trigger Standard mode:
<!--HTML 4.01 Strict--
<! DOCTYPE HTML PUBLIC "-//w3c//dtd HTML 4.01//en" "HTTP://WWW.W3.ORG/TR/HTML4/STRICT.DTD" >

<!--XHTML 1.0 Strict--
<! DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1.0 strict//en" "Http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd" >
Trigger quasi-standard mode:
<!--HTML 4.01 Transitions--
<! DOCTYPE HTML PUBLIC "-//w3c//dtd HTML 4.01 transitional//en" "HTTP://WWW.W3.ORG/TR/HTML4/LOOSE.DTD" >

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

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

<!--XHTML 1.0 Framework Set--
<! DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1.0 frameset//en" "Http://www.w3.org/TR/xhtml1/DTD/xhtml1-frameset.dtd" >
IE8 off in Super Standard mode:
<meta http-equiv= "x-ua-compatible" content= "ie=7"/>
The value of IE in the content property is used to specify which version of the rendering engine is used to render the page. This value is designed to be backwards compatible with sites and pages specifically designed for older versions of IE.

Doctype strict and promiscuous modes-how do you trigger these two patterns to differentiate between them?

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.