Forcing IE7 into standards rendering mode (not quirks)
Asked Answered
D

2

8

I'm having display issues in IE7 due to it rendering in quirks mode. I've confirmed this by displaying "document.compatMode" and getting back "BackCompat" as opposed to "CSS1Compat". Using IE8 and reverting to IE7 works, because that keeps it out of quirks. In plain IE8 I have it fixed by forcing the rendering mode with the X-UA-Compatible header, but this does not work for IE7. The other browsers also display in quirks, but unlike IE this does not put them into pseudo-IE5.5 mode, so they still render fine.

How can I force IE7 to render in standards rendering mode and not quirks? I've tried setting the DOCTYPE to a number of different options and I'm not adding the xml prologue. Thanks in advance for any replies.

Duo answered 9/2, 2011 at 14:32 Comment(2)
Can you past the first few lines of your page, or supply a link.Biquadrate
This question is pretty old, so I kind of doubt it's going anywhere. But I'm also interested in the answer to this. For various reasons, I cannot change the DOCTYPE on the page in question, and there's a great deal of invalid HTML which can't be easily changed. I'm wondering if IE7 has something similar to IE8's X-UA-Compatible. So far, it doesn't seem like it.Stipend
C
3

Did you try to the XHTML 4 strict DTD ?

<!DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml/DTD/xhtml1-strict.dtd">

Also beware that if there is anything before that DTD declaration, IE7 will still stay in quirk mode.

In other words:

IE7: strict

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">

or

<!DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">

IE7: quirk

<?xml version="1.0" encoding="UTF-8"?>
<!-- stuff -->
<!DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">

Where it gets nasty is that : IE6 takes the following as Quirk mode.

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
Catherinacatherine answered 9/2, 2011 at 14:44 Comment(0)
H
2

Have you run your code through the W3C validator?

If you have invalid HTML, IE may revert to quirks mode regardless of the doctype.

Hillman answered 9/2, 2011 at 16:19 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.