HTML under the special conditions in IE browser Comment explanation _ Experience Exchange
Source: Internet
Author: User
In the process of learning and applying Web standard Web pages, the compatibility of Web pages with browsers is an issue that is frequently contacted. Because Microsoft's Internet Explorer (IE) occupies more than half of the browser market, in addition to Firefox, opera and so on. These browsers need to be compatible.
At the same time, in the case of IE, because of the upgrade of the version of IE, the current visitors to use the main stay in IE5 (IE5.5), IE6 and IE7 three of the version. These 3 versions are not displayed in the same way as we do for the Web Standard Web page (XHTML+CSS) interpretations we make. Also, other non-ie browsers and IE do not have the same explanation for some CSS. Therefore, it is possible to define the relevant attribute by using the proprietary condition annotation in IE browser.
Original address: http://www.quirksmode.org/css/condcom.html
Conditional annotations can only be used with Explorer 5+ Windows (IE) (conditional comments are supported from IE5). If you have more than one IE installed, the conditional comment (Conditional comments) will be the highest version of IE (currently IE 7).
Conditional annotations are only available under Windows Internet Explorer (IE), so we can use conditional annotations to add special instructions to IE.
Popular point, conditional annotations are some if judgments, but these judgments are not executed in the script, but are executed directly in the HTML code, such as:
1, the basic structure of the conditional comment and the comment of the HTML ( ) is the same. Browsers outside of IE will therefore treat them as plain annotations and ignore them entirely.
2,ie will determine whether the content in the conditional comment is parsed as if the normal page content is parsed, based on the IF condition.
3, conditional annotations use the HTML annotation structure, so they can only be used in HTML files, not in CSS files.
You can use the following code to detect the current version of IE browser (note: In non-IE browser is not see the effect)
If the current browser is IE, but the version is lower than IE5, what to do, you can use
This distinguishes between IE7 and IE6 down the browser to the implementation of CSS, to achieve compatibility. At the same time, the first line of the default css.css can also be compatible with other non-IE browser implementations.
Note: The default CSS style should be in the first line of the HTML document, and all content judged by the conditional comment must be behind the default style.
For example, the following code, in IE, the execution of the display as red, and in non-IE browser display as black. If the conditional annotation is judged on the first line, it cannot be implemented. This example can explain the compatibility problem between IE and non-IE browser.
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.