Article introduction of Wulin.com (www.vevb.com): How to judge the IE version in HTML code.
How to make static HTML code display different content according to different IE versions. The trick here is to use IE's HTML annotation expression.
The comment format of HTML is <!-- Comment content --> . IE has made some extensions to HTML comments to support conditional judgment expressions:
<!--[if expression]> HTML <![endif]--> When the expression expression is True, the HTML content is displayed.
example:
view plaincopy to clipboardprint?
<!--[if IE 5]>
<p>Welcome to Internet Explorer 5.</p>
<![endif]-->
<!--[if IE 5]>
<p>Welcome to Internet Explorer 5.</p>
<![endif]-->
Similar to programming languages, expressions here also support operators such as greater than (gt), less than (lt), and or non. Here are some examples.
[if IE] Determine whether IE is
[if IE 7] Determine whether it is IE7
[if !IE] Determine whether it is not IE
[if lt IE 5.5] Determine whether it is IE5.5 or below. (<)
[if lte IE 6] Determine whether it is equal to IE6 version or below (<=)
[if gt IE 5] Determine whether IE5 or above (> )
[if gte IE 7] Determine whether IE7 version or above
[if !(IE 7)] Determine whether it is not IE7
[if (gt IE 5)&(lt IE 7)] Determine whether it is greater than IE5 and less than IE7
[if (IE 6)|(IE 7)] Determine whether IE6 or IE7
Code example:
view plaincopy to clipboardprint?
<!--[if IE]><p>You are using Internet Explorer.</p><![endif]-->
<![if !IE]><p>You are not using Internet Explorer.</p><![endif]>
<!--[if IE 7]><p>Welcome to Internet Explorer 7!</p><![endif]-->
<!--[if !(IE 7)]><p>You are not using version 7.</p><![endif]-->
<!--[if gte IE 7]><p>You are using IE 7 or greater.</p><![endif]-->
<!--[if (IE 5)]><p>You are using IE 5 (any version).</p><![endif]-->
<!--[if (gte IE 5.5)&(lt IE 7)]><p>You are using IE 5.5 or IE 6.</p><![endif]-->
<!--[if lt IE 5.5]><p>Please upgrade your version of Internet Explorer.</p><![endif]-->
<!--[if IE]><p>You are using Internet Explorer.</p><![endif]-->
<![if !IE]><p>You are not using Internet Explorer.</p><![endif]>
<!--[if IE 7]><p>Welcome to Internet Explorer 7!</p><![endif]-->
<!--[if !(IE 7)]><p>You are not using version 7.</p><![endif]-->
<!--[if gte IE 7]><p>You are using IE 7 or greater.</p><![endif]-->
<!--[if (IE 5)]><p>You are using IE 5 (any version).</p><![endif]-->
<!--[if (gte IE 5.5)&(lt IE 7)]><p>You are using IE 5.5 or IE 6.</p><![endif]-->
<!--[if lt IE 5.5]><p>Please upgrade your version of Internet Explorer.</p><![endif]-->
Note: This annotation extension is not supported in versions below IE5. But it's hard to find IE4 now... :)