"."/> ".">
Home > Article > Web Front-end > What are the ways to write CSS that are compatible with IE?
The CSS writing methods compatible with IE are: 1. Add "-" or "_" in front of the attribute, and the writing method is "_attribute: attribute value"; 2. CSS conditional comments, the syntax "26b118360b81b730c41bbd1a9843361c600536a2154dabda749cc62f31578fba1b771f47d72d900ba74308aee59557f0".
The operating environment of this tutorial: Windows 7 system, CSS3&&HTML5 version, Dell G3 computer.
1. Hack
Writing method:
.demo { margin-left:30px; _margin-left:20px; }
Advantages:
1. Embedded in CSS, it is very convenient when writing
2. Embedded in CSS, it will not generate more HTTP requests
Disadvantages:
1. Not unified in one module, later maintenance and modification will be troublesome
2. Even if this writing method does not work, the browser will load the code and waste resources
2. CSS conditional comments
Writing method:
<!--[if IE 6 ]> <link rel="stylesheet" type="text/css" media="all" href="./ie6.css" /> <![endif]-->
Advantages :
1. The code is independent, which is beneficial to later maintenance
2. For browsers where the code does not work, this code is just an ordinary comment and will not be loaded when they load it. Load its content and save resources
Disadvantages:
1. A new HTTP request is added, which undoubtedly increases the pressure on the old version of IE browser.
Extension:
HTML tag conditional comments
<!DOCTYPE html> <!--[if IE 6 ]> <html class="ie6 lte_ie6 lte_ie7 lte_ie8" lang="zh-CN"> <![endif]--> <!--[if lte IE 6 ]> <html class="lte_ie6 lte_ie7 lte_ie8" lang="zh-CN"> <![endif]--> <!--[if lte IE 7 ]> <html class="lte_ie7 lte_ie8" lang="zh-CN"> <![endif]--> <!--[if lte IE 8 ]> <html class="lte_ie8" lang="zh-CN"> <![endif]--> <!--[if (gte IE 9)|!(IE)]><!--><html lang="zh-CN"><!--<![endif]-->
.ie6 .demo { margin-left: 20px; }
This method can separate the code into a separate module and will not add a new HTTP request. Currently used more.
Recommended learning: css video tutorial
The above is the detailed content of What are the ways to write CSS that are compatible with IE?. For more information, please follow other related articles on the PHP Chinese website!