views:

11

answers:

2

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?

+3  A: 

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]-->
alex
That works. thanks.
hookedonwinter
+1  A: 

I don't think it's possible to test for quirks mode. Instead, use a DOCTYPE and make sure your HTML validates to it. XHTML DOCTYPEs are probably better.

alpha123
Going for `<!DOCTYPE html>`. Thanks!
hookedonwinter
Any strict doctype as well as the HTML5 doctype works, actually.
BoltClock
I don't know how well <!DOCTYPE html> (which is the HTML5 doctype) will work with IE8, given that it doesn't support HTML5, but it's worth a try. It's also the best doctype for forwards compatibility.
alpha123
@alpha123 it doesn't appear to change how ie8 in quirks mode renders, actually.
hookedonwinter
Try the HTML4.01 or XHTML 1.0 Transitional DOCTYPES. IE supports those. Also, be sure your (X)HTML validates to it's doctype. Try here ---> http://validator.w3.org/
alpha123