DTD and mode, DTD Mode

Source: Internet
Author: User
Tags website server

DTD and mode, DTD Mode
Summary

We must test ie when creating a page. After all, the market share of IE is still very high. With the popularity of HTML5, projects may require that the minimum IE version be IE8 or later, but many projects are compatible with earlier IE versions. Therefore, we often encounter page layout disorder in earlier versions of IE. This is because there are two modes of IE browser that affect the page. Now let's take a look at it.

Document verification mechanism (DTD)

DTD is a validation mechanism for html files and is part of html files. Three types of documents: S (Strict), T (Transitional), and F (Frameset ).

  • Strict
    Clean labels to avoid confusion on the presentation layer.
  • Transitional
    DTD can contain the rendering attributes and elements that W3C expects to move into the style sheet. If your readers use browsers that do not support Cascading Style Sheets (CSS), you must use the HTML Rendering feature.
  • Frameset
    DTD should be used for documents with frameworks. Except that the frameset element replaces the body element, the Frameset DTD is equivalent to the Transitional DTD.

HTML5 simplifies DTD and can be used directly <! Doctype html>.

Mode

The mode is mainly for ie browsers. In ie7 or lower, Microsoft's code standards differ from those set by W3C, but ie has a very large market share, therefore, developers will write code according to Microsoft's specifications. With the development of major browser vendors and the efforts of W3C organizations, browser standardization becomes more and more obvious. To be compatible with ie6/7, Microsoft added the pattern feature in the ie8 browser, which can solve problems caused by inconsistent code standards.

There are two modes: browser mode and document mode. What are the differences between the two models?

  • Browser Mode
    It is used to switch the default document mode of IE for the webpage, parse the conditional remarks of different browsers, and send the User-Agent string to the website server. The website can determine the browser version and installation function based on different user agent strings returned by the browser, so that different page content can be returned to different browsers. By default, IE8 adopts IE8 browser mode. You can switch to different browser modes manually.
  • Document Mode
    It is used to specify the version of the page layout engine (Trident) of IE to parse and render webpage code. Switching the document mode will cause the webpage to be refreshed, but the version number in the user agent string will not be changed or the webpage will not be re-downloaded from the server. When the browser mode is switched, the browser automatically switches to the corresponding document mode.

For the document mode, Each browser has a different working mode.

  IE6 IE7 IE8 IE9 IE10 Chrome Firefox Safari Opera
Quriks Mode) Yes Yes Yes Yes Yes Yes Yes Yes Yes
Close to standard Mode) None None Yes Yes Yes Yes Yes Yes Yes
Standard Mode) Yes Yes Yes Yes Yes Yes Yes Yes Yes

How do we control what document mode the browser uses to display pages?

<meta http-equiv="X-UA-Compatible" content="IE=edge">

The above code is used to specify that the IE browser renders the page in standard document mode. We can modify the edge to specify a specific version, for example, IE = 8.

What should I do to control this? Obviously, this element can tell the browser in what mode to use to render pages. Sometimes we can see normal content in the browser of higher IE versions, and the layout of earlier versions is messy, add the following and the correct DTD declaration.

< meta http-equiv = "X-UA-Compatible" content = "IE=edge,chrome=1" />

Determine the document mode of the current page

 1 <!DOCTYPE html> 2 

 

 

S (standard mode), A (close to standard mode), Q (Mixed Mode)

Doctype NS6 Old Moz Moz &
Safari &
Opera 10
&
IE10
& HTML5
Opera 9.0 IE 8, IE 9 & Opera 9.5 Internet Explorer 7 & operators' 7.10 Internet Explorer 6 & operators' 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

PS:

Opera document mode: http://www.opera.com/docs/specs/doctype/

Firefox document mode: https://developer.mozilla.org/en-US/docs/Mozilla%27s_DOCTYPE_sniffing

IE8: http://blogs.msdn.com/ B /ie/archive/2010/03/02/how-ie8-determines-document-mode.aspx

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.