Condition comment judgment browser & lt ;! -- [If! IE] & gt; & lt ;! -- [If IE] & gt; & lt ;! -- [If lt IE 6] & gt; & lt ;! -- [If gte IE 6] & gt;, ltgte

Source: Internet
Author: User
Tags html validator

Condition comment judgment browser <! -- [If! IE]> <! -- [If IE]> <! -- [If lt IE 6]> <! -- [If gte IE 6]>, ltgte

<! -- [If! IE]> <! --> All except IE can be recognized <! -- <! [Endif] -->
<! -- [If IE]> all IE identifiable <! [Endif] -->
<! -- [If IE 6]> only IE6 can recognize <! [Endif] -->
<! -- [If lt IE 6]> versions earlier than IE6 and IE6 are recognizable <! [Endif] -->
<! -- [If gte IE 6]> IE6 and IE6 and later versions can be recognized <! [Endif] -->
<! -- [If IE 7]> only IE7 is recognizable <! [Endif] -->
<! -- [If lt IE 7]> versions earlier than IE7 and IE7 are recognizable <! [Endif] -->
<! -- [If gte IE 7]> IE7 and IE7 versions can be identified <! [Endif] -->
<! -- [If IE 8]> only IE8 is recognizable <! [Endif] -->
<! -- [If IE 9]> only IE9 can recognize <! [Endif] -->

Project Example Description
! [If! IE] The NOT operator. This is placed immediately in front ofFeature,Operator, OrSubexpressionTo reverse the Boolean meaning of the expression.
NOT operator. This is an instant front.Function,Operator, OrSubexpressionReturns the meaning of a Boolean expression.
Lt [If lt ie5.5] The less-than operator. Returns true if the first argument is less than the second argument.
Less than the operator. If the first parameter is smaller than the second parameter, true is returned.
Lte [If lte IE 6] The less-than or equal operator. Returns true if the first argument is less than or equal to the second argument.
Less than or equal to the operation. If the first parameter is smaller than or equal to the second parameter, true is returned.
Gt [If gt IE 5] The greater-than operator. Returns true if the first argument is greater than the second argument.
Greater than the operator. If the first parameter is greater than the second parameter, true is returned.
Gte [If gte IE 7] The greater-than or equal operator. Returns true if the first argument is greater than or equal to the second argument.
Greater than or equal to the operation. If the first parameter is greater than or equal to the second parameter, true is returned.
() [If! (IE 7)] Subexpression operators. Used in conjunction with boolean operators to create more complex expressions.
Operator of the subexpression. Use the Boolean operator to create more complex expressions.
& [If (gt IE 5) & (lt IE 7)] The AND operator. Returns true if all subexpressions evaluate to true
AND operator. Returns true if all the subexpressions are calculated as true.
| [If (IE 6) | (IE 7)] The OR operator. Returns true if any of the subexpressions evaluates to true.
OR operator. Returns true if the subexpression returns true.

 

 

<! -- [If lt IE 9]>
Load CSS1
<! -- [Else]>
Load CSS2
<! [Endif] -->

This is valid, but an error is returned in html validator because it does not comply with the XHTML 1.1 specification,
If the ELSE statement is removed, it is correct.

 

Method 1:

Load CSS2
<! -- [If lt IE 9]>
Load CSS1 (you can write the code to be rewritten here ).
<! [Endif] -->


The HTML annotation format is that IE has made some extensions to HTML annotations so that it can support conditional judgment expressions. How can I make static HTML code

Similar to programming languages, the expressions here also support operators such as greater than (gt), less than (lt), and non-equal operators, conditional annotation is a unique extension of annotation in IE5.0 and later versions. It is not supported by other browsers. [If IE] determines whether IE [if IE 7] Is IE7 [if! IE] determines if it is not IE [if lt IE 5.5] and whether it is IE5.5 or earlier. (<) [If lte IE 6] determine whether it is equal to IE6 or earlier (<=) [if gt IE 5] determine whether it is IE5 or later (>) [if gte IE 7] determine whether IE7 or later [if! (IE 7)] Judging whether it is IE7 [if (gt IE 5) & (lt IE 7)] Judging whether it is greater than IE5, less than IE7 [if (IE 6) | (IE 7)] Judging whether IE6 or IE7 is a comprehensive example code for judging the IE version: <! -- [If IE]> You are using Internet Explorer. <! [Endif] --> <! -- [If! IE] --> You are not using Internet Explorer. <! -- [Endif] --> <! -- [If IE 7]> Welcome to Internet Explorer 7! <! [Endif] --> <! -- [If! (IE 7)]> You are not using version 7. <! [Endif] --> <! -- [If gte IE 7]> You are using IE 7 or greater. <! [Endif] --> <! -- [If (IE 5)]> You are using IE 5 (any version). <! [Endif] --> <! -- [If (gte IE 5.5) & (lt IE 7)]> You are using IE 5.5 or IE 6. <! [Endif] --> <! -- [If lt Internet Explorer 5.5]> Please upgrade your version of Internet Explorer. <! [Endif] --> for <! -[If expression]> HTML <! [Endif]->, non-IE browsers will be treated as comments, not displayed; For <! -[If expression]-> HTML <! -[Endif]->: Non-IE browsers are displayed as common code segments.

Does the CSS if condition Hack only apply to IE browsers?

Non-ie browsers can also be recognized: The specific application example is as follows:
<! -- [If IE]>

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.