Allows the webpage to display different content based on different IE versions

Source: Internet
Author: User
Tags html comment

This blog mainly describes how to make static HTML code display different content based on different IE versions. The trick here is to use the HTML comment expression of IE.
The HTML comment format is <! -- Comment content -->, IE extends HTML comments to support conditional expressions:
<! -- [If expression]> HTML <! [Endif] --> when expression is True, HTML content is displayed.
Example:
Copy codeThe Code is 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 operators such as greater than (gt), less than (lt), and or not. The following are some examples.
[If IE] determine whether IE
[If IE 7] determining whether it is IE7
[If! IE] determine if it is not IE
[If lt IE 5.5] determines whether it is IE5.5 or earlier. (<)
[If lte IE 6] determining whether it is equal to IE6 or earlier (<=)
[If gt IE 5] determine whether IE5 or later is used (>)
[If gte IE 7] determine whether IE7 or later is used
[If! (IE 7)] determine if it is not IE7
[If (gt IE 5) & (lt IE 7)] judge whether it is greater than IE5 and less than IE7
[If (IE 6) | (IE 7)] determine whether IE6 or IE7 is used
Sample Code:
Copy codeThe Code is 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 Internet Explorer 5.5]> <p> Please upgrade your version of Internet Explorer. </p> <! [Endif] -->

Related Article

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.