Search This Blog

Jun 7, 2012

TIPS: Internet Explorer CSS Hacks

Even though it is not a best practice to use hacks in targeting IE6, IE7 and IE8 stylesheets, it is still important to know when and how you can use them. And besides, it is fun to fix IE issues, right? :))

Hacking IE8 and Below
Using "\9", you can target Internet Explorer 8 and below. Appending it on your style and let the magic happens.
For example:
#myId {
  color:red ; /*this will affect all browsers including IE */
  color:blue\9; /* this will override the style above on IE8 and below browser*/
}
IE7 and Below
Using star (*) symbol on before the style.
#myId {
  color:red ; /*this will affect all browsers including IE */
  *color:blue; /* this will override the style above on IE7 and below browser*/
}
And lastly, the OLD IE6
Targeting IE6 is by using the underscore before the style, like this:
#myId {
  color:red ; /*this will affect all browsers including IE */
  _color:blue; /* this will override the style above on IE7 and below browser*/
}
Please take note that I’m not promoting to use hacks here. I only used these hacks if there are one or two changes. If there are handful changes, please make sure that you use the CSS conditional statement for better maintenance and avoid confusions.

0 comments: