Internet Explorer version of the syntax to determine the use of

Source: Internet
Author: User

Let's start with the IE version syntax.
<!--[If LTE IE 6]><! [Endif]-->ie6 and the following versions are visible <!--[if LTE IE 7]><! [Endif]-->ie7 and the following versions are visible <!--[if IE 6]><! [endif]--> only IE6 version visible <! [If! ie]><! [endif]> except IE version <!--[if Lt IE 8]><! [ENDIF]-->IE8 versions below are visible <!--[if GTE IE 7]><! [Endif]-->ie7 and versions larger than IE7 are visible
Determine the usage of IE version

1, 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]>       <H1>You are using IE browser</H1>       <!––[if IE 5]>           <H2>Version 5</H2>       <![endif]––>       <!––[if IE 5.0]>           <H2>Version 5.0</H2>       <![endif]––>       <!––[if IE 5.5]>           <H2>Version 5.5</H2>       <![endif]––>       <!––[if IE 6]>           <H2>Version 6</H2>       <![endif]––>       <!––[if IE 7]>           <H2>Version 7</H2>       <![endif]––><![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 the conditional annotation can only be in the ie5+ environment, so it <!–[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 of the JavaScript is not equal to the same judge

2, how conditional annotations should be applied
This article at the beginning of the explanation, because the browser version of the Internet Explorer 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. Like what:

<!–-default call css.css style sheet 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.

<style type= "Text/css" >body {Background-color: #000;} </style><!-–[if ie]><style type= "Text/css" >body {Background-color: #F00;} </style><! [endif]–->

At the same time, some people will try to use to define the situation under the non-IE browser, but note: The conditional comment can only be executed under IE browser, this code is not executed under this condition in non-ie browsing, but is ignored 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.
These comments are already preinstalled in the Dreamweaver4 and above versions: in the "window –> code snippet –> notes" .

Open direct use is very convenient.

Internet Explorer version of the syntax to determine the use of

Related Article

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.