Friday, May 22, 2009

IE8 CSS Hack

So the quick hack I found last night does indeed work. Here is the breakdown of IE hacks:

div {
   color: black; /* works for all browsers */
   color: red\9; /* works for IE8 and below */
   *color: green; /* works for IE7 and below */
   _color: blue; /* works for IE6 and below */
}

1 comment:

Unknown said...

Thanks for posting this! I couldn't figure out what was causing a 16-pixel gap between the top of the screen and the first div tag in IE8. Looked fine on a Mac with margin: 0 auto; but for IE, I had to change to margin: -16px auto 0 auto; How frustrating but I'm glad now it looks right.