Comments for IE6, 7, and 8 conditions (css is not required for IE display in different versions)

Source: Internet
Author: User
Tags versions


I. INTRODUCTION to condition comments

1. Conditional comments in IE is a common hack method in WEB design, which can distinguish IE versions from non-IE versions.
2. Condition annotations can only be used for IE5.
3. If you have installed multiple IE, the condition annotation will be based on the IE of the highest version.
4. Basic structure of condition comments and HTML comments (<! -->) Is the same. Therefore, browsers other than IE will regard them as common comments and ignore them completely.
5. IE will determine whether to parse the content in the condition comment just like the normal page content based on the if condition.

II. Condition annotation attributes

Gt: greater than. Select a conditional version or a later version, excluding the conditional version.
Lt: less than: Select a version earlier than the conditional version, excluding the conditional version.
Gte: greater than or equal. Select the conditional version or later, including the conditional version.
Lte: less than or equal. Select a version earlier than the required version, including the required version.
! : Select All versions other than the conditional version, regardless of the level


1. Css if hack condition syntax
<! -- [If IE]> Only IE <! [Endif] -->
Only all WIN systems with 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] -->
Both IE5.0 and IE5.5 can be identified.
 
<! -- [If lt IE 6]> Only IE 6-<! [Endif] -->
Only IE6 can recognize
 
<! -- [If gte IE 6]> Only IE 6/+ <! [Endif] -->
IE5.x under IE6 and IE6 can be recognized
 

<! -- [If lte IE 7]> Only IE 7/-<! [Endif] -->
Only IE7 can recognize
 
<! -- [If gte IE 7]> Only IE 7/+ <! [Endif] -->
IE6 and IE5.x under IE7 and IE7 can be recognized
 

<! -- [If IE 8]> Only IE 8/-<! [Endif] -->
Only IE8 can recognize
 

<! -- [If IE 9]> Only IE 9/-<! [Endif] -->
Only IE9 can recognize

 
Note: Adding lt gte after if has different effects (the same applies to other parameters)
<! -[If IE 8]> = IE8 is only recognizable by IE8
<! -[If lt IE 8]> = IE7 or earlier

<! -[If gte IE 8]> = later than or equal to IE8
The following code is a condition comment for running in a non-IE browser

<! -- [If! IE]> <! -->
You are not using Internet Explorer
<! -- <! [Endif] -->
<! -- [If IE 6]> <! -->
You are using Internet Explorer version 6 or a non-IE browser
<! -- <! [Endif] -->


<! DOCTYPE html>
<Html>
<Head>
<Meta http-equiv = "Content-Type" content = "text/html; charset = utf-8"/>
<Title> div if condition instance </title>
</Head>
<Body>
You are using:
<! -- [If IE 7]>
<H2> IE7 <! [Endif] -->
<! -- [If IE 6]>
<H2> IE6 <! [Endif] -->
<! -- [If IE 8]>
<H2> IE8 <! [Endif] -->
     
<! -- [If IE 9]>
<H2> IE9 <! [Endif] -->
<Br>
<Strong> description </strong>: If your browser version is, it will show how much IE, for the IE6-IE9 experiment </body>
</Html>

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.