Table of Contents
The role of DOCTYPE and the difference between standards mode and compatibility mode" >The role of DOCTYPE and the difference between standards mode and compatibility mode
Home Web Front-end HTML Tutorial The difference between the role of doctype and the standards mode and compatibility mode

The difference between the role of doctype and the standards mode and compatibility mode

Mar 25, 2017 am 10:13 AM
doctype Compatibility mode Standard mode

The role of DOCTYPE and the difference between standards mode and compatibility mode

  1. ## declaration must be at the head of the HTML document Before the tag,

    tells the browser's parser what document standard to use to parse this document. A non-existent or incorrectly formatted DOCTYPE will cause the document to be rendered 's typesetting and JS operation mode are all run at the highest standards supported by the browser. In Compatibility Mode, pages are displayed in a loosely backwards-compatible manner, simulating the behavior of older browsers to prevent the site from not working. Specific differences:

    1. Box model

    In strict mode: width is the content width, and the real width of the element = width;
    In compatibility mode: width is =width+ padding+border
    2. In compatibility mode, you can set the percentage height and the height and width of inline elements
    In Standards mode, setting wdith and height for inline elements such as span will not take effect, but in compatibility mode, will take effect.
    In standards mode, the height of an element is determined by the content it contains. If the parent element does not set a height, setting a percentage height of the child element is invalid.
    3. Using margin:0 auto to set horizontal centering will not work under IE
    Using margin:0 auto can center the element horizontally in standards mode, but it will not work in compatibility mode (use the text-align attribute) Solution)
    body{text-align:center};#content{text-align:left}
    4. In compatibility mode, the font attributes in Table cannot inherit the settings of the upper layer, and white-space:pre will be invalid. Setting the padding of the image will be invalid

      The statement must be at the head of the HTML document, before the tag,
    1. Inform the browser's parser to use What document standard parses this document. A non-existent or incorrectly formatted DOCTYPE will cause the document to be rendered

      in compatibility mode. HTML5 is case-insensitive

    2. declaration is not an HTML tag, but a directive used to tell the browser the current HTMl version
    3. The HTML layout engine of modern browsers determines whether to use compatibility mode or standards mode to render the document by checking the doctype. Some browsers have a near-standards model.
    4. The declaration in HTML4.01 points to a DTD. Since HTML4.01 is based on SGML, the DTD specifies markup rules to ensure that the browser renders the content correctly
    5. HTML5 is not based on SGML, so there is no need to specify a DTD
    ##The difference between standard mode and compatibility mode

    : Standard mode's typesetting and JS operation mode are all run at the highest standards supported by the browser. In Compatibility Mode, pages are displayed in a loosely backwards-compatible manner, simulating the behavior of older browsers to prevent the site from not working. Specific differences: 1. Box model

    In strict mode: width is the content width, and the real width of the element = width;

    In compatibility mode: width is =width+ padding+border
    2. In compatibility mode, you can set the percentage height and the height and width of inline elements
    In Standards mode, setting wdith and height for inline elements such as span will not take effect, but in compatibility mode, will take effect.
    In standards mode, the height of an element is determined by the content it contains. If the parent element does not set a height, setting a percentage height of the child element is invalid.
    3. Using margin:0 auto to set horizontal centering will not work under IE
    Using margin:0 auto can center the element horizontally in standards mode, but it will not work in compatibility mode (use the text-align attribute) Solution)
    body{text-align:center};#content{text-align:left}
    4. In compatibility mode, the font attributes in Table cannot inherit the settings of the upper layer, and white-space:pre will be invalid. Setting the padding of the image will be invalid

    The above is the detailed content of The difference between the role of doctype and the standards mode and compatibility mode. For more information, please follow other related articles on the PHP Chinese website!

Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
1 months ago By 尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. Best Graphic Settings
1 months ago By 尊渡假赌尊渡假赌尊渡假赌
Will R.E.P.O. Have Crossplay?
1 months ago By 尊渡假赌尊渡假赌尊渡假赌

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

What does word compatibility mode mean? What does word compatibility mode mean? Mar 05, 2021 am 11:40 AM

Compatibility mode is a mode provided by the office software for the program. It is set up so that the old version of the software can run within the new framework. Under compatibility mode, documents of the old version of Word can be used normally in the new version, or the file format of the new version can be used normally in the old version. It can also be run in . However, some new features will be disabled when older versions are used.

How to change excel table compatibility mode to normal mode How to change excel table compatibility mode to normal mode Mar 20, 2024 pm 08:01 PM

In our daily work and study, we copy Excel files from others, open them to add content or re-edit them, and then save them. Sometimes a compatibility check dialog box will appear, which is very troublesome. I don’t know Excel software. , can it be changed to normal mode? So below, the editor will bring you detailed steps to solve this problem, let us learn together. Finally, be sure to remember to save it. 1. Open a worksheet and display an additional compatibility mode in the name of the worksheet, as shown in the figure. 2. In this worksheet, after modifying the content and saving it, the dialog box of the compatibility checker always pops up. It is very troublesome to see this page, as shown in the figure. 3. Click the Office button, click Save As, and then

How to set Google Chrome compatibility mode How to set Google Chrome compatibility mode Jan 30, 2024 am 08:24 AM

Google Chrome is one of the most popular browsers and has won the hearts of users with its powerful features and convenience. However, to ensure that certain web pages or applications can display and function properly, or to be more compatible with older web standards, we may need to have Google Chrome run in a different compatibility mode. So, how to set Google Chrome compatibility mode? Don’t worry if you don’t know yet, let’s take a look at how to set up compatibility mode to help you enjoy using Google Chrome at its best. How to set Google Chrome compatibility mode 1. Click to open Google Chrome, click the menu, and click "Settings". 2. Find "Default Browser Settings" in the settings and click to turn on "Allow Internet Exp

How to set compatibility mode in 2345 browser? How to set compatibility mode in 2345 browser? Jan 30, 2024 am 10:27 AM

2345 browser is a popular browser tool among users. The compatibility mode setting is an important operation, which is related to the user's experience when browsing the web. Good compatibility mode settings can make the display effect of web pages clearer and more stable, and avoid various display abnormalities or incompatibility problems. So how to set the 2345 browser compatibility mode? Don’t worry if you are still unclear. Next, the editor will bring you the steps to set up the compatibility mode. I hope it can help you. How to set the 2345 browser compatibility mode. Method 1: 1. Open the 2345 browser and click the "lightning" icon above. 2. Then select "ie compatibility mode" in the pop-up menu bar. Method two: 1. Open the 2345 browser and click on the upper right

How to set 360 speed browser compatibility mode How to set 360 speed browser compatibility mode Feb 24, 2024 am 10:49 AM

360 Speed ​​Browser is a popular browser application that allows users to access the Internet quickly and securely. In order to solve the problem of abnormal page display or inability to use functions normally, 360 Extreme Browser provides a compatibility mode function to allow users to browse the web better. So how to set the 360 ​​speed browser compatibility mode? Don’t worry, the editor will bring you a tutorial on how to set up the compatibility mode of 360 Extremely Fast Browser. I hope it can help you. How to set the compatibility mode of 360 Speed ​​Browser 1. Open the 360 ​​Speed ​​Browser downloaded from this site. After opening the software, click the three horizontal bars icon in the upper right corner. 2. Click [Settings] in the pop-up options. 3. Click in the opened 360 Speed ​​Browser settings window

How to set edge browser compatibility mode How to set edge browser compatibility mode Feb 28, 2024 pm 08:31 PM

How to set edge browser compatibility mode? The edge browser is the default browser for Windows systems. It is simple to operate, extremely convenient to use, and has rich and complete functions. But many people don’t know how to set the compatibility mode of edge browser. Today, I will provide you with a method to set the compatibility mode of the edge browser. I hope this tutorial can help those who are not familiar with the compatibility mode of the edge browser. Come and try it! Method for setting compatibility mode in Edge browser: 1. Open the browser on your computer, enter the homepage, and click the three small dots icon in the upper right corner. 2. In the drop-down pop-up window that pops up, find and click to set this option below the pop-up window. 3. After switching to the settings page, click on the left side of the page

How to enable compatibility mode in Google Chrome How to enable compatibility mode in Google Chrome Jan 30, 2024 pm 01:00 PM

How to enable Google Chrome compatibility mode? When we use Google Chrome, we may access multiple tabs at the same time. At this time, there may be problems with lag and smoothness. We can solve the above problems by turning on the compatibility mode in Google Chrome and enjoy compatible and stable Internet browsing services. If you don’t know how to turn on the compatibility mode, follow the editor to take a look at the compatibility mode setting tutorial. . How to turn on Google Chrome compatibility mode 1. Open Google Chrome and click "Settings"; 2. Turn on "Allow website reloading in Internet Explorer mode" and click Restart; 3. After restarting Google Chrome, select "In Internet Explorer mode" Heavy

How to set 360 browser compatibility mode? How to turn on the 360 ​​browser compatibility mode? How to set 360 browser compatibility mode? How to turn on the 360 ​​browser compatibility mode? Mar 13, 2024 pm 09:20 PM

360 Browser is a very easy-to-use and convenient search tool. Many users don’t know how to turn on the compatibility mode of 360 Browser. Then let this site introduce 360 ​​to users in detail. How to turn on browser compatibility mode. How to turn on the 360 ​​browser compatibility mode? 1. Open the 360 ​​browser and enter the corresponding web page. 2. Click the "Compatibility" icon on the right side of the address bar (shown as a puzzle shape), or press the shortcut key F7. 3. In the pop-up compatibility settings window, select the compatibility mode you want to use: - You can select "IE8 Compatible" to simulate the behavior of Internet Explorer 8

See all articles