CSS Hacks for IE6,IE7,IE8,IE9 and IE10

Here are the newest CSS hacks for IE all versions, compatible with Firefox and Chrome.

#hack{
color:red; /* All browsers */
color:red !important;/* All browsers but IE6 */
_color:red; /* Only works in IE6 */
*color:red; /* IE6, IE7 */
+color:red;/* Only works in IE7*/
*+color:red; /* Only works in IE7 */
color:red\9; /* IE6, IE7, IE8, IE9 */
color:red\0; /* IE8, IE9 */
color:red\9\0;/*Only works in IE9*/
}

For your information, these hacks could not pass the W3C CSS Validator, lucky for us, here is a more standard hack for IE10.

. ie10 #hack{
color:red; /* Only works in IE10 */
}

You see, the reason it works is that IE10 put a class=”ie10″ to the <html> tag, which is very convenient for us to write any hack towards IE10.

Comments

  1. says

    Hey Guys,

    You can use for IE10 below

    Add in the head section:

    var b = document.documentElement;
    b.setAttribute(‘data-useragent’, navigator.userAgent);
    b.setAttribute(‘data-platform’, navigator.platform );

    Thanks.
    Nitin Sharma
    nitinwebs@gmail.com
    minecreativity.com

    And add style in the style.css:
    html[data-useragent*='MSIE 10.0'] .in-side-nav{
    background:#000;
    }

  2. rudolf says

    It would be nice if people stopped using IExplorer altogether, but alas 25% of my visitors still use it. I tried to implement your suggestion with other css attributes but it does not work for me.
    Safest way remains using a separate styule sheet. If only customers would pay for the extra work ;-(

Leave a Reply to Dillon McCallum Cancel reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>