HTML to determine IE version

Source: Internet
Author: User

HTML to determine IE version1. <!--[if! ie]><!--> In addition to IE can be recognized <!--<! [Endif]-->2. <!--[ifie]> All IE recognizable <! [Endif]-->3. <!--[ifIE 5.0]> only IE5.0 can recognize <! [Endif]-->4. <!--[ifIE 5]> only IE5.0 and IE5.5 can be identified <! [Endif]-->5. <!--[ifGT IE 5.0]> IE5.0 and IE5.0 above can be identified <! [Endif]-->6. <!--[ifIE 6]> only IE6 recognizable <! [Endif]-->7. <!--[ifLt IE 6]> IE6 and IE6 The following versions are recognized <! [Endif]-->8. <!--[ifGTE IE 6]> IE6 and IE6 above are recognized <! [Endif]-->9. <!--[ifIE 7]> only IE7 recognizable <! [Endif]-->10. <!--[ifLt IE 7]> IE7 and IE7 The following versions are recognized <! [Endif]-->11. <!--[ifGTE IE 7]> IE7 and IE7 above are recognized <! [endif]--><!--[ifLTE IE 6]>......<! [endif]-->ite:less than or equal to meaning is less than or equal to IE6 browser, for the conditions of IE browser comments, commonly used in csshack, for IE, JS and so on. 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 IE version of replacement, the current visitors use the main stay in IE5 (IE5.5), IE6 and IE7 in the three versions. And these 3 versions are for the Web standard Web pages we make (xhtml+CSS) Explains how the execution is displayed in different states. 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. Conditional annotations can only be used for explorer5+ Windows (hereinafter referred to as IE) (conditional annotations are supported starting 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:<!--[ifIe]>here is the normal HTML code<! [Endif]-->1, basic structure of conditional annotations and comments on 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 according to the IF condition. 3, conditional annotations Use the HTML annotation structure, so they can only be used in HTML files and 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)<!--[ifIe]> ifIE 5]> ifIE 5.0]> ifIE 5.5]> ifIE 6]> ifIE 7]> If the current browser is IE, but the version is lower than IE5, what to do, you can use<!--[ifLS IE 5]>, of course, according to conditional annotations can only be in ie5+ environment, so <!--[ifLS IE 5]>will not be executed at all. LTE: is less than or equal to the shorthand, that is, smaller than or equal to the meaning. LT: is less than shorthand, that is, smaller than the meaning. GTE: is greater than or equal to the shorthand, that is, greater than or equal to the meaning. GT: is greater than shorthand, that is, the meaning of greater than. !: is not equal to the meaning, and JavaScript is not equal to the same judge conditional comments belongs to the CSS hack?does the conditional judgment belong to CSS hack? Strictly speaking, it belongs to CSS hack. Because it's like any other real CSS hack, it allows us to give special styles to some browsers, and it doesn't depend on a browser bug to control the other browser (style). In addition, conditional judgment can be used to do things beyond the bounds of the CSS hack (although this rarely happens). Because the conditional judgment does not depend on the hack of a particular browser, it is a thoughtful feature, so I believe it can be used with confidence. Of course, other browsers may also support conditional judgments (not so far), but it seems that they should not use<!--[ifIe]>such a syntax. How to apply conditional annotations This article begins with the explanation, because the browser version of the Internet browsers for our production of the Web Standard page interpretation is not the same, in particular, the interpretation of the CSS is different, we are compatible with these, we can use conditional comments to define, and finally achieve the purpose of compatibility. For example:<!--by default call css.css style sheet--><link rel= "stylesheet" type= "Text/css" href= "css.css"/><!--[ifie 7]><!--If IE browser version is 7, call IE7.CSS style sheet--><link rel= "stylesheet" type= "Text/css" href= "Ie7.css"/><! [endif]--><!--[ifLTE IE 6]><!--if IE browser version is less than or equal to 6, call Ie.css style sheet--><link rel= "stylesheet" type= "Text/css" href= "Ie.css"/> <! [endif]-->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. <style type= "Text/css" >Body{background-color: #000;}</style><!--[ifIe]><style type= "Text/css" >Body{background-color: #F00;}</style><! [endif]-->at the same time, someone will try to use<!--[if! Ie]>to define a condition that is not in IE, but note that conditional annotations can only be performed under IE, and this code is not defined under this condition in non-ie browsing, but is ignored as annotations. Normal is the default style, for IE browser needs special processing, only to make conditional comments. In the HTML file, but not in the CSS file. 

HTML to determine IE version

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.