Condition annotations differentiate non-ie browsers

Source: Internet
Author: User
Although the conditional comments of IE browser are not commonly used, they are extremely powerful and can be used to differentiate the version of IE browser.

<! -- [If IE]> only ie <! [Endif] -->
All ie identifiable
<! -- [If IE 5.0]> only IE 5.0 <! [Endif] -->
Only ie5.0 can recognize
<! -- [If gt ie 5.0]> only IE 5.0 + <! [Endif] -->
Higher than ie5.0 can be identified
<! -- [If lt IE 6]> only IE 6-<! [Endif] -->
Less than IE6 recognizable
<! -- [If gte ie 6]> only IE 6/+ <! [Endif] -->
Both IE6 and IE6 can be identified.
<! -- [If lte ie 7]> only IE 7/-<! [Endif] -->
Versions earlier than IE7 and IE7 are recognizable

LTE: Short for less than or equal to, that is, less than or equal.

LT: Short for less than, that is, less.

GTE: Short for greater than or equal to, that is, greater than or equal.

GT: Short for greater than, that is, greater.

! : It means not equal to, which is the same as the non-equal identifier in JavaScript.

Only the <! -- [If! IE]> not ie <! [Endif] --> is that okay?

If you think so, it will be wrong, because non-ie does not recognize the IE conditional comments, so it is all comments directly,
OK. Let's take a look at the correct method.

<! -- [If! IE]> < -->
Only Internet Explorer can see this
<! [Endif] -- > I was going to add some content here, which can only be seen by non-ie and encoded by the editor. ^ _ ^. Try it now. Only non-ie can see it,
The key is the header after the condition annotation <-> It is treated as an internal comment in IE, and the comment is closed in a non-IE browser. To distinguish non-ie browsers, which are generally used <! ->.

From: http://blog.silentash.com/2010/03/conditional-comments-for-ie-and-non-ie-browsers/

 

More:


1 <! -- [If lt IE 7]> <HTML class = "ie IE6"> <! [Endif] -- >
2 <! -- [If IE 7]> <HTML class = "ie IE7"> <! [Endif] -- >
3 <! -- [If IE 8]> <HTML class = "IE8"> <! [Endif] -- >
4 <! -- [If IE 9]> <HTML class = "ie9"> <! [Endif] -- >
5 <! -- [If (GT ie 9) |! (IE)]> <! -- > < Html > <! -- <! [Endif] -- >
6

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.