Wednesday, September 1, 2010

How to style for IE6, IE7, and IE8 without conditional comments

Suppose the page you're fixing is in an iframe and you're not allowed to change the HTML and can only make adjustments to one CSS file.  No conditional comments then.  Even worse, there is no DOCTYPE on the page, and so it ends up sending the browser into quirks mode.  Here's the CSS-hacky way to target specific versions of IE:
  • IE8 and below:  put a "\9" at the end of the style value
    { width:98px\9; }
  • IE7 and below:  put a "*" at the beginning of the property name
    { *width:80px; }
  • IE6:  put an "_" at the beginning of the property name
    { _width:106px; }

No comments:

Post a Comment