Ie6,ie7,ie8,firefox compatible CSS hack detailed

Source: Internet
Author: User

Has published about this CSS compatible hack article more than one, but there are too many, have been invalidated, again released, do not want to talk about what a mess of the theory, directly on the example! As follows:
IE browser can recognize "*" "\9", standard browser (such as FF) does not recognize "*";
IE6 can recognize "_" "+" "#" "@", the same attribute has two only look at the latter, whether or not if it is two words it can recognize the "!important";
IE7 can recognize "+" "#" "@" "!important", Can not recognize "_";
FF can recognize "!important", Cannot recognize "_" "+" "#" "@";

The above is my own test results, if there are errors also please point out ~, or you have a good compatibility method,

Note: No matter what method, the order of writing is Firefox written in the front, IE7 written in the middle, IE6 written in the last side.
For example:

The code is as follows Copy Code
select{
color:blue;//all Browsers
color:yellow\9;//All IE browsers
*color:red;//forie7
_color:green;//forie6
}

Attention to IE8 CSS hack people believe that everyone is using this hack, is the "9" CSS hack:
Where: Op said Opera,sa said Safari,ch said Chrome, of course, if you have the patience to test "\14", "\15", "\16" ...
From the above test results we can see that "the" is only IE8 recognition, IE6,IE7 can not recognize, then "the" should be IE8 real hack. Mainstream browser CSS hack this is better:

The code is as follows Copy Code
. test{
Color: #000000; /* FF,OP Support * *
Color: #0000FF; /* IE8 Support * *
[Color: #000000; color: #00FF00;/* SF,CH Support * *
*color: #FFFF00; /* IE7 Support * *
_color: #FF0000; /* IE6 Support * *
}

Where: Op said Opera,sa said Safari,ch said Chrome;
Attention to IE8 CSS hack people believe that everyone is using this hack, is the "9" CSS hack:

The code is as follows Copy Code
. test{
Color: #000000; /* FF,OP Support * *
Color: #0000FF \9; /* All IE browser (ie6+) support, but IE8 does not recognize the "*" and "_" CSS hack; so we can write hack * *
[Color: #000000; color: #00FF00;/* SF,CH Support * *
*color: #FFFF00; /* IE7 Support * *
_color: #FF0000; /* IE6 Support * *
}

Color: #0000FF \9 hack support IE6-IE8 (not tested in other versions), but IE8 does not recognize "*" and "_" CSS hack, so we can use
Color: #0000FF \9; ;/*ie6,ie7,ie8*/
*color: #FFFF00;/*ie7*/
_color: #FF0000/*ie6*/to differentiate IE versions.

Finally, take Microsoft to provide three kinds of parsing pages in IE8 mode


IE8 Standard Modes: The default of the most standard mode, strictly in accordance with the relevant rules of the Consortium
IE7 Standards MODES:IE7 is now used to parse the Web page mode, open the organization is in Quirks MODES:IE5 used to parse the model of the Web page, the open authority is to delete the HTML top of the DOCTYPE declaration
Note: Pages in different modes can frame each other in IE8, therefore, because the DOM and CSS rendering is not the same, it will cause a lot of problems, it is important to note that if your page is IE7 compatible with no problem, and do not want to modify the existing code in large quantities, but also in the IE8 normal use, Microsoft said, Developers only need to add a line of code to the currently compatible IE7 Web site to solve the problem, as follows:


Example Source Code
<meta http-equiv= "x-ua-compatible" content= "ie=7″/>
IE8 Latest CSS hack:


"9″ Example:" margin:0px auto9; Here's "9″ can distinguish all IE and Firefox."
"*" IE6, IE7 can be identified. IE8, Firefox can't.
"_" IE6 can Identify "_", IE7, IE8, Firefox can not.

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.