I. Introduction to Conditional Annotation
Conditional comments (Conditional comments) in the version of IE and IE non-IE has excellent ability to distinguish between IE, is a common hack method in WEB design.
2. Conditional comments can only be used in IE5 or above.
3. If you have more than one IE installed, the conditional comment will be based on the highest version of IE.
4. The basic structure of conditional comments and HTML comments (<! ->) are the same. Therefore, browsers other than IE will regard them as ordinary comments and completely ignore them.
The if condition will be used to determine whether to parse the content of the conditional comment as if it were normal page content.
II. Conditional Annotation Properties
gt : greater than, selects versions above the conditional version, does not include the conditional version
lt : less than, selects versions below the conditional version, not including the conditional version
gte : greater than or equal, select the version above the conditional version, include the conditional version
lte : less than or equal, selects the version below the conditional version, contains the conditional version
! : Select all versions other than the conditional version, high or low
1, Css if hack conditional syntax
< !--[if IE]> Only IE <![endif]-->
Only recognized by all WIN systems with IE.
< !--[if IE 5.0]> Only IE 5.0 <![endif]-->
Only IE5.0 can recognize it.
< !--[if gt IE 5.0]> Only IE 5.0+ <![endif]-->
IE5.0 package for IE5.5 can be recognized
< !--[if lt IE 6]> Only IE 6- <![endif]-->
Only recognized by IE6
< !--[if gte IE 6]> Only IE 6/+ <![endif]-->
IE6 and below are recognized.
<!--[if lte IE 7]> Only IE 7/- <![endif]-->
Only recognized by IE7
< !--[if gte IE 7]> Only IE 7/+ <![endif]-->
IE7 and IE6 below IE7 are recognized.
<!--[if IE 8]> Only IE 8/- <![endif]-->
Only recognized by IE8
<!--[if IE 9]> Only IE 9/- <![endif]-->
Only recognized by IE9
Note: Adding lt gte after if makes a difference (same for all other parameters).
<! -[if IE 8]> = IE8 Only IE8 is recognized.
<! -[if lt IE 8]> = IE7 or lower
<! -[if gte IE 8]> = higher than or equal to IE8 version
The following code is a conditional comment that runs in non-IE browsers
<!--[if !IE]><!-->
You are not using Internet Explorer
<!--<![endif]-->
<!--[if IE 6]><!-->
You are using Internet Explorer version 6 or a non-IE browser.
<!--<![endif]-->
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title> DIV IF Condition Example </title>
</head>
<body>
You're using:
<!--[if IE 7]>
<h2>IE7</h2>
<![endif]-->
<!--[if IE 6]>
<h2>IE6</h2>
<![endif]-->
<!--[if IE 8]>
<h2>IE8</h2>
<![endif]-->
<!--[if IE 9]>
<h2>IE9</h2>
<![endif]-->
<br><br>
<strong> Description </strong>: If your browser version for how much that will show IE how much, for IE6-IE9 experiments </body>
</html>
Conditional comments (Conditional comments) in the version of IE and IE non-IE has excellent ability to distinguish between IE, is a common hack method in WEB design.
2. Conditional comments can only be used in IE5 or above.
3. If you have more than one IE installed, the conditional comment will be based on the highest version of IE.
4. The basic structure of conditional comments and HTML comments (<! ->) are the same. Therefore, browsers other than IE will regard them as ordinary comments and completely ignore them.
The if condition will be used to determine whether to parse the content of the conditional comment as if it were normal page content.
II. Conditional Annotation Properties
gt : greater than, selects versions above the conditional version, does not include the conditional version
lt : less than, selects versions below the conditional version, not including the conditional version
gte : greater than or equal, select the version above the conditional version, include the conditional version
lte : less than or equal, selects the version below the conditional version, contains the conditional version
! : Select all versions other than the conditional version, high or low
1, Css if hack conditional syntax
< !--[if IE]> Only IE <![endif]-->
Only recognized by all WIN systems with IE.
< !--[if IE 5.0]> Only IE 5.0 <![endif]-->
Only IE5.0 can recognize it.
< !--[if gt IE 5.0]> Only IE 5.0+ <![endif]-->
IE5.0 package for IE5.5 can be recognized
< !--[if lt IE 6]> Only IE 6- <![endif]-->
Only recognized by IE6
< !--[if gte IE 6]> Only IE 6/+ <![endif]-->
IE6 and below are recognized.
<!--[if lte IE 7]> Only IE 7/- <![endif]-->
Only recognized by IE7
< !--[if gte IE 7]> Only IE 7/+ <![endif]-->
IE7 and IE6 below IE7 are recognized.
<!--[if IE 8]> Only IE 8/- <![endif]-->
Only recognized by IE8
<!--[if IE 9]> Only IE 9/- <![endif]-->
Only recognized by IE9
Note: Adding lt gte after if makes a difference (same for all other parameters).
<! -[if IE 8]> = IE8 Only IE8 is recognized.
<! -[if lt IE 8]> = IE7 or lower
<! -[if gte IE 8]> = higher than or equal to IE8 version
The following code is a conditional comment that runs in non-IE browsers
<!--[if !IE]><!-->
You are not using Internet Explorer
<!--<![endif]-->
<!--[if IE 6]><!-->
You are using Internet Explorer version 6 or a non-IE browser.
<!--<![endif]-->
Copy Code The code is as follows.
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title> DIV IF Condition Example </title>
</head>
<body>
You're using:
<!--[if IE 7]>
<h2>IE7</h2>
<![endif]-->
<!--[if IE 6]>
<h2>IE6</h2>
<![endif]-->
<!--[if IE 8]>
<h2>IE8</h2>
<![endif]-->
<!--[if IE 9]>
<h2>IE9</h2>
<![endif]-->
<br><br>
<strong> Description </strong>: If your browser version for how much that will show IE how much, for IE6-IE9 experiments </body>
</html>