Browser condition Comment

Source: Internet
Author: User

Original link: http://www.blueidea.com/tech/site/2006/3561.asp

Browser conditional annotation theory, using the following example to explain the problem

X Html

The following section of code is the effect of testing conditional comment statements under Microsoft's IE browser:

<!--[If ie]>
<! [endif]-->
<!--[if IE 5]>
<! [endif]-->
<!--[if IE 5.0]>
<! [endif]-->
<!--[if IE 5.5]>
<! [endif]-->
<!--[if IE 6]>
<! [endif]-->
<!--[if IE 7]>
<! [endif]-->

The following code is a conditional comment that runs in a non-IE browser:

<!--[if! ie]><!-->
<!--<! [endif]-->
Ultimately works in non-IE and special IE browsers
(or use LTE LT or GT GTE to judge, such as:
<!--[If LTE IE 6]>
Information displayed under IE 6
<! [endif]-->
).

<!--[if IE 6]><!-->
or a non-ie browser <!--<! [endif]-->

From:http://www.cssplay.co.uk/menu/conditional.html

Conditional comments are only supported by IE after Ie5.0/win, and are generally used for hack.
X Html
The following section of code is the effect of testing conditional comment statements under Microsoft's IE browser

<!--[If ie]>
Judging by the conditions, this is the Internet explorer<br/>
<! [endif]-->
<!--[if IE 5]>
According to the conditions, this is Internet Explorer 5<br/>
<! [endif]-->
<!--[if IE 5.0]>
According to the conditions, this is Internet Explorer 5.0<br/>
<! [endif]-->
<!--[if IE 5.5]>
According to the conditions, this is Internet Explorer 5.5<br/>
<! [endif]-->
<!--[if IE 6]>
According to the conditions, this is Internet Explorer 6<br/>
<! [endif]-->
<!--[if IE 7]>
According to the conditions, this is Internet Explorer 7<br/>
<! [endif]-->
<!--[if GTE IE 5]>
Depending on the condition, this is Internet Explorer 5 or higher <br/>
<! [endif]-->
<!--[If Lt IE 6]>
According to the conditions, this is the version of the Internet explorer<br less than 6/>
<! [endif]-->
<!--[If LTE IE 5.5]>
Depending on the condition, this is Internet Explorer 5.5 or lower <br/>
<! [endif]-->

The following code is a conditional comment that runs under a non-IE browser

<!--[if! ie]><!-->
You are not using the Internet explorer<br/>
<!--<! [endif]-->
<!--[if IE 6]><!-->
You are using Internet Explorer version 6<br/>
or a non-ie browser <br/>
<!--<! [endif]-->

The following is the syntax for conditional annotations:

[List]
[*]gt/greater than/greater than/<!--[if GT IE 5.5]>
[*]gte/greater than or equal to/greater than or equal to/<!--[if GTE IE 5.5]>
[*]lt/less than/less than/<!--[if Lt IE 5.5]>
[*]lte/less than or equal to/less than equals/<!--[if LTE IE 5.5]>
[*]! /note/is not equal to/<!--[if! IE 5.5]>
[/list]

IE conditional annotations of excellent browser-differentiated capabilities, allowing many designers to use hack to resolve browser differences in CSS parsing

<!--[if IE6.0]]
<style type= "Text/css" >
div#box{width:500px;margin:10px; padding:10px; border:10px;}
</style>
<! [endif]-->
<!--[if Lt IE6.0]]
<style type= "Text/css" >
div#box{width:530px;margin:10px; padding:10px; border:10px;}
</style>

Browser condition Comment

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.