Advantages and disadvantages of conditional comments in IE

Advantages and disadvantages of conditional comments in IE

IE's conditional comments are a proprietary (and therefore non-standard) Microsoft extension to regular (X)HTML comments.
IE's conditional comments are a proprietary (and therefore non-standard) Microsoft extension to regular (X)HTML comments. As the name suggests, conditional comments enable you to display a block of code based on a condition (such as the browser version). Although non-standard, conditional comments appear as regular comments to all other browsers and are therefore essentially harmless. Conditional comments first appeared in IE5 on Windows and have been supported by all subsequent versions of the Windows browser.
IE's conditional comments are extremely effective and very easy to remember. The main disadvantage is that these comments need to be placed in the HTML page, not in the CSS. In this way, when you don't need these things or make some changes, you need to maintain a lot of places.
Let’s look at a few examples –
Only IE can recognize it <br />Because only IE5 and above versions support IE conditional comments, so "only IE" can recognize it means "only IE5 and above versions" can recognize it.

Only specific versions can be recognized <br />For example, only IE5 can be recognized, only IE6 can be recognized, only IE7 or IE8 can be recognized. The identification condition is a specific version, neither higher nor lower versions are acceptable. For example, the following code block will only work in IE8
<!--[if IE 8]>
<style type="text/css">
@import "test.css";
</style>
<![endif]-->


Only versions that are not specific can be recognized . Of course, IE browser needs to be version 5 or above to be within the scope of discussion. For example, in the following example, IE7 is specified as not being recognized.
<!--[if !IE 7]>
<style type="text/css">
@import "test.css";
</style>
<![endif]-->


Previous Page 1 2 3 Next Page Read More

<<:  Vue installation and use

>>:  How to add docker port and get dockerfile

Recommend

Design theory: people-oriented design concept

<br />When thoughts were divided into East a...

MySQL date processing function example analysis

This article mainly introduces the example analys...

Windows Server 2008 Tutorial on Monitoring Server Performance

Next, we will learn how to monitor server perform...

Implementation of iview permission management

Table of contents iview-admin2.0 built-in permiss...

Vue uses the Element el-upload component to step on the pit

Table of contents 1. Basic Use 2. Image quantity ...

4 ways to avoid duplicate insertion of data in Mysql

The most common way is to set a primary key or un...

MySQL 8.0.12 Installation and Configuration Tutorial

This article records the detailed tutorial for in...

How to uninstall MySQL 5.7.19 under Linux

1. Find out whether MySQL was installed before Co...

Solution to the Multiple primary key defined error in MySQL

There are two ways to create a primary key: creat...

CSS to achieve text on the background image

Effect: <div class="imgs"> <!-...

vsCode generates vue templates with one click

1. Use the shortcut Ctrl + Shift + P to call out ...

Summary of MySQL common functions

Preface: The MySQL database provides a wide range...

Install Docker on Centos7 (2020 latest version available, just copy and paste)

Refer to the official documentation here for oper...

HTML CSS3 does not stretch the image display effect

1. Use the transform attribute to display the ima...