Home  >  Article  >  Web Front-end  >  What is Quirks mode? How is it different from Standards mode?

What is Quirks mode? How is it different from Standards mode?

一个新手
一个新手Original
2017-10-14 09:24:511952browse

What is Quirks mode? What is the difference between it and Standards mode?

Starting from IE6, the Standards mode was introduced. In the standards mode, the browser tries to give the documents that comply with the standards the correct specification. Processed to the extent available in a given browser.

CSS was not mature enough before IE6, so browsers prior to IE5 had poor support for CSS. IE6 will provide better support for CSS. However, problems arise at this time, because there are many The pages are written based on the old layout method, and if IE6 supports CSS, these pages will display abnormally. How can we ensure that the existing pages are not destroyed and provide a new rendering mechanism?

We often encounter this problem when writing programs, how to ensure that the original interface remains unchanged and provide more powerful functions, especially when the new functions are not compatible with the old functions. A common approach when encountering this kind of problem is to add parameters and branches, that is, when a certain parameter is true, we use the new function, and if the parameter is not true, we use the old function, so that it does not destroy The original program also provides new functions. IE6 does something similar. It treats DTD as this "parameter". Because no one would write DTD on previous pages, so IE6 assumes that if DTD is written, it means that this page will use better support for CSS. layout, and if not, the previous layout will be compatible. This is Quirks mode (quirks mode, weird mode, weird mode).

Difference:

There will be overall differences in three aspects: layout, style analysis and script execution.

Box model: In the W3C standard, if you set the width and height of an element, it refers to the width and height of the element content. In Quirks mode, the width and height of IE also include padding and border. .

Set the height and width of inline elements: In Standards mode, setting wdith and height for inline elements such as will not take effect, but in quirks mode, it will take effect.

Set percentage height: In standards mode, the height of an element is determined by the content it contains. If the parent element does not set a percentage height, it is invalid for the child element to set a percentage height. margin:0 auto sets horizontal centering: Using margin:0 auto can center the element horizontally in standards mode, but it will fail in quirks mode.

The above is the detailed content of What is Quirks mode? How is it different from Standards mode?. For more information, please follow other related articles on the PHP Chinese website!

Statement:
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