Wednesday, August 22, 2007

IE CSS hack, including IE7

Okay, most of the hacks you've put in your CSS for IE6 and earlier are no longer needed in IE7 (hurrah!) but there may still be the odd occasion where your sites are now being drawn wrong by IE7. How do you change your CSS hacks so that they work for IE7 in the same was as IE6?
    /* text green in IE (both 6 & 7) */
    .classname {color: green;}

    /* text red in Safari and Firefox */
    html:not([dummy]) .classname {color; red}

Use this one sparingly, but it could be a lifesaver if a site is misbehaving in IE7 and you need to get things working using a fix that you've already applied for IE6. (Note: this one isn't always Opera friendly). If you really need a more thorough, and complicated, hack, have a quick google, but I recommend using this hack as firefighting fix while you get on and re-code your site to behave in IE7 without CSS hacks or filters.

No comments: