Chimera Studios' blog

IE8 CSS Hack

Posted by: chimerastudios on: 16 June, 2010

IE8 CSS hackIf like us you’re still having problems with IE8 behaving differently to all the GOOD browsers out there, fear not. Even with all the CSS reset code you can still run into those niggly problems that hold you up, but don’t worry, because there is a simple and effective IE8 CSS hack that works with Internet Explorer 8 without causing problems for Chrome, Firefox, Opera or Safari.

All you need to do, is put a “\9″ at the end of the CSS you want to only run in IE8. To give you an example, the following will display a blue border in Chrome, Firefox and Safari, but red in Internet Explorer 8.

border:solid 10px blue;
border:solid 10px red\9;

This is because the first 3 browsers only see the first line, but IE8 sees the next line, over-riding the previous statement.

Advertisement

1 Response to "IE8 CSS Hack"

border: solid 10px blue; /* targets all browsers, of course */
border: solid 10px red\9; /* targets IE8, IE7 and IE6 */
*border: solid 10px yellow; /* targets IE7 and IE6 */
_border: solid 10px orange; /* targets IE6 */

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Connecting to %s

Our latest tweets

Follow

Get every new post delivered to your Inbox.