IE to judge IE version of the statement [if LTE IE 8] ... [EndIf]

Source: Internet
Author: User
Tags comments first row versions

<!--[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 versions are visible
<! [If! Ie]>
<! [endif]>
In addition to IE version
<!--[If Lt IE 8]>
<! [endif]-->
IE8 The following version is visible
<!--[if GTE IE 7]>
<! [endif]-->
IE7 and larger than IE7 versions are visible
Usage:
(1)
You can use the following code to detect the version of the current IE browser (note: No effect is visible in non IE browsers)
<!––[if ie]>
<!––[if IE 5]>
<! [endif]––>
<!––[if IE 5.0]>
<! [endif]––>
<!––[if IE 5.5]>
<! [endif]––>
<!––[if IE 6]>
<! [endif]––>
<!––[if IE 7]>
<! [endif]––>
<! [endif]––>
If the current browser is IE, but the version is lower than IE5, how to do it, you can use <!–[if ls ie 5]&gt, of course, according to the conditional annotation can only be under the ie5+ environment, so <!–[if ls ie 5]> will not be executed at all.
LTE: Is the shorthand for less than or equal to, meaning less than or equal to.
LT: It is the shorthand for less than, which means less than.
GTE: is the shorthand for greater than or equal to, which is greater than or equal to the meaning.
GT: is the shorthand for greater than, which means greater than.
! : Is not equal to the meaning, and JavaScript is not equal to the same judge character
(2)
How conditional comments should be applied
This article explained at the outset, because IE each version of the browser to our web Standard page interpretation is not the same, specifically to the CSS interpretation of different, we in order to compatible with these, we can use conditional annotation to define, and ultimately achieve compatibility purposes. Like what:
<!–-The CSS.CSS style sheet is called first by default –->
<link rel= "stylesheet" type= "Text/css" href= "Css.css"/>
<!-–[if IE 7]>
<!–-if the IE browser version is 7, call IE7.CSS style sheet-–>
<link rel= "stylesheet" type= "Text/css" href= "Ie7.css"/>
<! [endif]–->
<!–-[if LTE IE 6]>
<!–-if the 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 the IE7 and IE6 down browsers from the implementation of CSS to achieve compatibility. At the same time, the default css.css of the first line can also be compatible with other non IE browsers.
Note: The default CSS style should be in the first row of the HTML document, and all content judged by the conditional annotation must be in the default style.
For example, the following code, in IE browser execution is displayed in red, and in non-IE browser display as black. If you put a conditional comment on the first line, you cannot implement it. This example can explain the Web page to the Internet Explorer and non-IE browser compatibility problem resolution.
<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, someone will try to use <!–-[if! Ie]> to define the situation in non-ie browsers, but note that conditional annotations can only be performed under IE, which is not a single definition of the condition under IE, but a blind eye to annotations.
Normal is the default style, for IE browser needs special treatment, only to make conditional comments. In an HTML file, but not in a CSS file.
The DWCS4 is now equipped with these notes: In the window--> code fragment--> comment. The other versions didn't notice much.

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.