Forcing IE7 into standard-rendering mode (not quirks)

I'm having problems displaying in IE7 due to its rendering in quirks mode. I confirmed this by showing "document.compatMode" and returning "BackCompat" as opposed to "CSS1Compat". Using IE8 and returning to IE7 works because it does not allow it to be avoided. In simple IE8, I fixed this by forcing a render mode with the header X-UA-Compatible, but this does not work for IE7. Other browsers also appear in quirks, but unlike IE, this does not put them in pseudo-IE5.5 mode, so they still display a penalty.

How to get IE7 to display standards rather than quirks in render mode? I tried setting DOCTYPE to several different parameters and I am not adding xml prolog. Thanks in advance for any answers.

+8
internet-explorer-7 rendering quirks-mode
source share
2 answers

Have you tried to execute strict DTD XHTML 4?

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

Also be careful if there is something before the DTD declaration, IE7 will still remain 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 this is unpleasant is that IE6 uses the following 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"> 
+3
source share

Did you run your code with the W3C validator ?

If you have invalid HTML, IE can return to quirks mode regardless of the type of doctype.

+2
source share

All Articles