Conditional annotations (Reprinted from the network) and IE annotations in ie
IE condition annotation is a non-standard logical statement provided by Microsoft since IE5. It allows you to flexibly import different html elements to browsers of different IE versions, such as style sheets, html tags. Obviously, the biggest benefit of this method lies in the compatibility solution officially provided by Microsoft and the W3C validation. Let's take a few examples to see: 1. Only Internet Explorer can recognize it <! -- [If IE]> <link type = "text/css" rel = "stylesheet" href = "my.css"/> <! [Endif] --> because only IE5 and later versions support IE conditional comments, all "only IE" can recognize that "only IE5 and later versions can be recognized. 2. Only a specific version can be identified <! -- [If IE 8]> <link type = "text/css" rel = "stylesheet" href = "my.css"/> <! [Endif] --> identify a specific IE version, which is neither high nor low. Only ie8. 3. Only versions that are not specific can be identified <! -- [If! IE 7]> <link type = "text/css" rel = "stylesheet" href = "my.css"/> <! [Endif] --> in the previous example, the specified IE7 version cannot be identified, and other versions can be identified. Of course, it must be in IE5 or later versions. 4. Only Versions later than a specific version can be identified <! -- [If gt IE 7]> <link type = "text/css" rel = "stylesheet" href = "my.css"/> <! [Endif] --> in the preceding example, only Versions later than IE7 can be identified. IE7 cannot be identified. 5. equal to or higher than a specific version for identification <! -- [If gte IE 7]> <link type = "text/css" rel = "stylesheet" href = "my.css"/> <! [Endif] --> IE7 and later versions can be identified in the preceding example. 6. Only versions earlier than the specified version can be identified. <! -- [If lt IE 7]> <link type = "text/css" rel = "stylesheet" href = "my.css"/> <! [Endif] --> in the preceding example, only versions earlier than IE7 can be identified, and IE7 cannot. 7. Only versions equal to or earlier than a specific version can be recognized <! -- [If lte IE 7]> <link type = "text/css" rel = "stylesheet" href = "my.css"/> <! [Endif] --> IE7 and earlier versions can be identified in the preceding example. The code above can be hard to remember. In fact, it is easy to remember to explain the keywords a little. Lt: Short for Less than, that is, Less. Lte: Short for Less than or equal to, that is, Less than or equal. Gt: Short for Greater than, that is, Greater. Gte: Short for Greater than or equal to, that is, Greater than or equal.!: It means not equal, which is the same as the non-equal identifier in javascript. This explains whether it is easy to remember more. Note: 1. Someone will try to use it! -- [If! IE]> to define a situation in a non-IE browser, but note: the conditional annotation can only be executed in IE, and this Code is ignored as a comment in a non-IE browser. 2. We usually use IE condition annotations to load different css files based on different browsers to solve style compatibility issues. In fact, it can do more. It can protect any code block-HTML code block, JavaScript code block, server code ...... Take a look at the following code. <! -- [If IE]> <script type = "text/javascript"> alert ("you are using IE browser! "); </Script> <! [Endif] -->