Search code examples
htmlinternet-explorer-8quirks-mode

Conditional HTML to target ie8 quirks mode


I have a page that's not displaying correctly in ie8 quirks mode. If I want to create some CSS to target just that mode, but not ie8 normally, what would be the conditional HTML?

For example, if I wanted to just hit ie8:

<!--[if IE 8]>
    awesome hacky stuff goes here
<![endif]-->

So what is the IE 8 part for ie8 quirks?


Solution

  • You can't use conditional comments to target a browser's rendering mode (just versions).

    If you are in quirks mode, use a doc type that doesn't invoke it.

    Unless, you are referring to IE8's compatibility mode, which makes the browser render similar to IE7. In that case, use the following conditional comment...

    <!--[if IE 7]>
        awesome hacky stuff goes here
    <![endif]-->