CSS style (compatibility) for IE browser

Source: Internet
Author: User

1. IE Hacks:

"_" is the exclusive hack of IE6; "\9" is effective for Ie6-ie10, "Ie9-ie10" is effective for ie8-ie10, and "\9\0" is effective for both;


CSS hacks embedded in the normal CSS, will not produce more HTTP requests. CSS hacks embedded in the normal CSS, it is more convenient to write.


It is a non-standard product. Embedded in other CSS, inconvenient to maintain. Especially when the number of hacks is more than the time to maintain is simply a nightmare. Embedded in other CSS, even in non-IE browser will be loaded, wasting resources.

2. Conditional comment CSS:

<!--[if IE 6]> < link rel= "stylesheet" type= "Text/css" media= "All" href= "./ie6.css"/><! [endif]-->

<! [endif]-->

Conditional annotations are an miscrosoft extension of IE proprietary to regular (X) HTML annotations. It is also a non-standard product from the standard, but it is Microsoft's official launch of the way for IE to develop,

And the conditional comment appears as a regular comment for all other browsers, so it is harmless to other browsers


The advantage of conditional comment CSS is that it is written in a standalone CSS file, which can control the load in specific IE without wasting resources and is easy to maintain.


is to generate extra HTTP requests, especially when you need a compatible version of IE a lot of time, you need to generate multiple HTTP requests, which would have been less than the number of low-version IE will undoubtedly affect the page loading speed.

The above two methods are not very good, the following methods are relatively good points;

3. Conditional Comment HTML tags:

  This scheme also uses conditional annotations, but does not use conditional annotations on CSS, but instead uses conditional annotations on HTML tags, introducing different classes to differentiate between IE and other browsers;

<!DOCTYPE HTML>  <!--[If IE 6]>  -  <!--[If LTE IE 6]>  -  <!--[If LTE IE 7]>  -  <!--[If LTE IE 8]>  -  <!--[If (GTE IE 9) |! (IE)] ><! -<HTMLLang= "ZH-CN"><!--<! [EndIf] -

Then add the corresponding class to the CSS of the specific IE and write it in the normal CSS file:. IE6. header. Nav {margin:0 0 0;p adding:0 0 0 0; }


The advantage of conditional comment expressions is that they do not produce extra HTTP requests;


Since these CSS for specific IE and the normal CSS put together, that is not the corresponding IE will be loaded, so if the number of CSS more than the words will be like using hacks, resulting in waste;

The above method: need to choose the method according to the specific situation.

CSS style (compatibility) for IE browser

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.