Strict mode and hybrid mode-how to trigger these two modes to differentiate their significance.
In standard mode, the browser displays the page according to the specifications;
In hybrid mode, the page is displayed in a loose backward compatible mode.
The browser selects the rendering method to use based on whether the doctype exists and the DTD used. If the XHTML document contains a complete doctype, it is generally presented in standard mode. For HTML 4.01 documents, the doctype containing a strict DTD often causes the page to be displayed in standard mode. The doctype that contains the transition DTD and Uri also results in page rendering in standard mode. However, if there is a transition DTD and no Uri, the page will be displayed in mixed mode. If the doctype does not exist or the format is incorrect, HTML and XHTML documents are displayed in a hybrid mode.
The Declaration is located at the beginning of the document, before the label. This label tells the browser document which HTML or XHTML specification is used.
The tag can declare three types of DTD, namely strict version, transitional version, and framework-based HTML document. See http://www.w3school.com.cn/tags/tag_doctype.asp for details
1. browser Mode
When browser vendors start creating standard-compatible browsers, they want to ensure backward compatibility. To achieve this, they created two rendering modes: standard mode and quirks mode ). In standard mode, the browser presents the page according to the specification. in hybrid mode, the page is displayed in a loose backward compatible mode. Hybrid mode typically simulates the behavior of older browsers (such as Microsoft IE 4 and Netscape Navigator 4) to prevent the old site from working.
Mozilla and Safari also have a third mode called "almost standard mode (almost standards mode)", in addition to slight differences in the way tables are processed, this mode is the same as the standard mode.
In Firefox, you can use Web Developer extension to view the page rendering mode. If the website is displayed in standard mode, a green hook is displayed on the toolbar. If it is displayed in mixed mode, it is displayed in red. The development tool in IE 8 also shows the browser usage mode.
Differences:
One of the most significant differences between the two modes is related to the dedicated Windows ie box model. When IE 6 appears, the correct box model is used in the standard mode, while the old proprietary box model is used in the hybrid mode. To maintain backward compatibility with IE 5 and earlier versions, opera 7 and later also use the defective ie Box Model in mixed mode.
Other differences in rendering are relatively small and related to specific browsers, this includes the # sign not required for hexadecimal color values, assuming that the unit of length without a specified unit in CSS is pixel, and adding the font size to a level when using keywords.
How to trigger these two modes:
The browser selects the rendering method to use based on whether the doctype exists and the DTD used. If the XHTML document contains a complete doctype, it is generally presented in standard mode. For HTML 4.01 documents, the doctype containing a strict DTD often causes the page to be displayed in standard mode. The doctype that contains the transition DTD and Uri also results in page rendering in standard mode. However, if there is a transition DTD and no Uri, the page will be displayed in mixed mode. If the doctype does not exist or the format is incorrect, HTML and XHTML documents are displayed in a hybrid mode.
Select the rendering mode based on whether the doctype exists. It is called doctype switching or doctype detection. Not all browsers use these rules, but these rules demonstrate how doctype switches work. For more information, see the website region.
Doctype switching is a method used by the browser to distinguish legacy documents from compliant documents. Whether or not effective CSS is compiled, if the wrong doctype is selected, the page will be displayed in a mixed mode, and its behavior may be wrong or unpredictable. Therefore, you must include a complete doctype Declaration on each page of the site, and select a strict DTD when using HTML.
<PRE>
<Ol>
<Li> & lt ;! Doctype HTML public "-// W3C // dtd html 4.01 // en" </LI>
<Li> "http://www.w3.org/TR/html4/strict.dtd" & gt; </LI>
<Li> & lt ;! Doctype HTML public "-// W3C // dtd xhtml 1.0 strict // en" </LI>
<Li> "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd" & gt; </LI>
<Li> & lt ;! Doctype HTML & gt; </LI>
</OL>
</PRE>
Many HTML editors automatically add the doctype declaration. If you create an XHTML document, some old editors may add an XML declaration before the doctype declaration:
<? XML version = "1.0" encoding = "UTF-8"?>
An XML Declaration is an optional declaration used by an XML file. It defines settings such as the XML version and character encoding type. Unfortunately, if the doctype declaration is not the first element on the page, ie 6 will automatically switch to the hybrid mode. This problem has been corrected in IE 7, but it is best to avoid using XML declaration unless the page is used as an XML document.