This blog is mainly about how to let static HTML code display different content according to different IE versions. The trick here is to use IE's HTML annotation expression.
The annotation format for HTML is <!--Comment content-->, IE extends HTML annotations so that they can support conditional judgment expressions:
<!--[if expression]> HTML <! [endif]--> Displays HTML content when the expression expression is true.
Example:
Copy Code code as follows:
<!--[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, the expressions here also support greater-than (GT), less-than (LT), and or non-operator characters. Here are some examples.
[If IE] to determine whether IE
[If IE 7] to determine whether it is IE7
[If! IE] to determine if it is not ie
[If Lt IE 5.5] Determines whether the following version is IE5.5. (<)
[If LTE IE 6] is judged to be equal to IE6 version or below (<=)
[If GT IE 5] To determine whether IE5 above version (>)
[If GTE IE 7] determine if IE7 version or above
[If! (IE 7)] Judge whether it is not IE7
[If (GT IE 5) & (LT IE 7)] is judged to be greater than IE5, less than IE7
[If (IE 6) | (IE 7)] Judge whether IE6 or IE7
code example:
Copy Code code as follows:
<!--[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]-->