Determine the version of IE browser in HTML

Source: Internet
Author: User
Tags html comment

How to let static HTML code display different content according to different IE versions. The trick here is to take advantage of IE's HTML comment expression.

The HTML annotation format is <!--Comment Content--IE has extended some HTML annotations to support conditional judgment expressions:

<!--[if expression]> HTML <! [endif]--> Displays HTML content when the expression is true.

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]-->

Like the programming language, the expressions here also support greater than (GT), less than (LT), and or non-equal operators. Here are some examples.

[If IE] determine if IE

[If IE 7] determine if it is IE7

[If! IE] to determine whether it is not ie

[If Lt IE 5.5] determine if it is IE5.5 the following version. (<)

[If LTE IE 6] Determine if it is equal to the IE6 version or the following (<=)

[If GT IE 5] To determine whether IE5 above version (>)

[If GTE IE 7] determine if IE7 version or above

[If! (IE 7)] Judging if it's not IE7

[If (GT IE 5) & (LT IE 7)] determine if it is greater than IE5, less than IE7

[If (IE 6) |  (IE 7)] Judging whether IE6 or IE7

code example:

View Plaincopy to Clipboardprint?
<!--[if ie]><p>you are using the Internet explorer.</p><! [endif]-->
<! [If! Ie]><p>you is not using the Internet explorer.</p><! [endif]>

<!--[if IE 7]><p>welcome to Internet Explorer 7!</p><! [endif]-->
<!--[if! ( IE 7)]><p>you is not using version 7.</p><! [endif]-->

<!--[if GTE ie 7]><p>you is using IE 7 or greater.</p><! [endif]-->
<!--[if (ie 5)]><p>you is using IE 5 (any version). </p><! [endif]-->
<!--[if (GTE IE 5.5) & (LT IE 7)]><p>you is using IE 5.5 or IE 6.</p><! [endif]-->
<!--[if LT IE 5.5]><p>please upgrade your version of the Internet explorer.</p><! [endif]-->
<!--[if ie]><p>you are using the Internet explorer.</p><! [endif]-->
<! [If! Ie]><p>you is not using the Internet explorer.</p><! [endif]>

<!--[if IE 7]><p>welcome to Internet Explorer 7!</p><! [endif]-->
<!--[if! ( IE 7)]><p>you is not using version 7.</p><! [endif]-->

<!--[if GTE ie 7]><p>you is using IE 7 or greater.</p><! [endif]-->
<!--[if (ie 5)]><p>you is using IE 5 (any version). </p><! [endif]-->
<!--[if (GTE IE 5.5) & (LT IE 7)]><p>you is using IE 5.5 or IE 6.</p><! [endif]-->
<!--[if LT IE 5.5]><p>please upgrade your version of the Internet explorer.</p><! [endif]-->

Note: This annotation extension is not supported in versions below IE5. But it's hard to find IE4 now ...:)


Determine the version of IE browser in HTML

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.