The statement of IE version in IE environment

Source: Internet
Author: User

HTML to determine IE version 1.<!--[if! ie]><! -can be recognized except IE<!--<! [EndIf] -2.<!--[If ie]> all IE recognizable <! [EndIf] -3.<!--[If IE 5.0]> only IE5.0 can be identified <! [EndIf] -4.<!--[If IE 5]> only IE5.0 and IE5.5 can be identified <! [EndIf] -5.<!--[If GT IE 5.0]> IE5.0 and IE5.0 above can be identified <! [EndIf] -6.<!--[If IE 6]> only IE6 recognizable <! [EndIf] -7.<!--[If Lt IE 6]> IE6 and IE6 The following versions are recognized <! [EndIf] -8.<!--[If GTE IE 6]> IE6 and IE6 above are recognized <! [EndIf] -9.<!--[If IE 7]> only IE7 recognizable <! [EndIf] -.<!--[If Lt IE 7]> IE7 and IE7 The following versions are recognized <! [EndIf] -One by one .<!--[If GTE IE 7]> IE7 and IE7 above are recognized <! [EndIf] -<!--[If LTE 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 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. 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:<!--[If ie]> here is the normal HTML code <! [EndIf] -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 ie]>  -      <!--[If IE 5.0]>  -      <!--[If IE 5.5]>  -      <!--[If IE 6]>  -      <!--[If IE 7]>  -<![endif]-->If the current browser is IE, but the version is lower than IE5, what to do, you can use<!--[if LS ie 5]>, of course, according to conditional annotations can only be in ie5+ environment, so <!--[if LS 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 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 syntax such as <!--[if ie]>. 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:<!--call the CSS.CSS style sheet by default first -<Linkrel= "stylesheet"type= "Text/css"href= "Css.css" /><!--[If IE 7]><!--if IE browser version is 7, call IE7.CSS style sheet -<Linkrel= "stylesheet"type= "Text/css"href= "Ie7.css" /><![endif]--><!--[If LTE IE 6]><!--if IE browser version is less than or equal to 6, call IE.CSS style sheet -<Linkrel= "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. <styletype= "Text/css">Body{Background-color:#000;}</style><!--[If Ie]><style type= "Text/css" >body{background-color: #F00;} </style><! [EndIf] -at the same time, someone will try to use<!--[if! Ie]> to define the condition under the non-IE browser, but note: The conditional comment can only be executed under IE browser, this code does not execute the definition under this condition under non-ie browsing, but ignores it as a comment. 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. 

Source: http://www.oschina.net/code/snippet_575130_12609

The statement of IE version in IE environment

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.