HTML5 doctype putting IE9 into quirks mode?
Asked Answered
M

5

101

I'm trying to get IE9 to load my page with IE9 standards...

I noticed having <!DOCTYPE HTML> puts the damn thing into quirks mode... Which pretty much breaks everything on page...

How do I get IE to stick to IE9 Standards?

Merlynmermaid answered 30/6, 2011 at 3:45 Comment(4)
@EricLaw - Huh? I don't follow...Merlynmermaid
What is the URL of your page that reproduces this problem.Mckie
Its an internal testing page I'm using... But nvm, @David_Wick already answered the question... :-)Merlynmermaid
See also #3726857Embowed
F
134

Placing:

<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">

in the <head> tag should do it.

Ferrite answered 30/6, 2011 at 3:49 Comment(5)
Yup, that did the trick... Could you please explain this a little bit for me?Merlynmermaid
@Abhishek: meta elements need not be explicitly closed in HTML5 (and historically against older HTML specs closing it would in fact be invalid).Doyenne
@Doyenne - If you look at the history, you'll see that he had originally left off the closing bracket (>).Prow
Does it have to be the first or only meta tag? Because it is in there and still defaults to quirks mode.Litigable
I found out that putting this meta tag right after the <head> tag will work, while having it at the bottom of <head> might not work, probably due to other content interfering.Mite
Z
63

Make sure you don't have any HTML comments before the DOCTYPE declaration otherwise it will trigger IE9 to use quirks mode.

Just having <!DOCTYPE html> at the very top of the page with nothing preceding it should be enough to make IE9 use standards mode. You shouldn't need the meta tag as well.

Zellers answered 5/9, 2011 at 21:20 Comment(3)
@frumbert: except that case has comments before the doctype declaration, so no.Doyenne
except that these are not treated as html comments, they are conditional comments which IE(any) doesn't interpret as part of the dom, whereas html comments (those without square brackets in them) are treated as dom and therefore behind whitespace. Depends on the case, the version of ie and the doctype being used.Jillion
No it doesn't, zuallauz said comments, and your examples have comments (whether they're standard HTML or not or interpreted as desired only by IE or not is irrelevant).Doyenne
W
5

Using the WebBrowser control to display HTML will use IE8 rendering, regardless of doctype, unless you specify

<meta http-equiv="X-UA-Compatible" content="IE=9" />

or

<meta http-equiv="X-UA-Compatible" content="IE=edge" />
Wed answered 7/5, 2012 at 21:14 Comment(0)
D
4

Remove any unsupported comments, check for ie supported comments. And place in your head tag. The doc type declaration should be the very 1st line in your HTML.

Dixil answered 20/6, 2012 at 6:38 Comment(0)
G
0

I have in the head mentioned in all the pages. However it is just showing correctly for the home page for all other pages the page is still rendered in scattered mode.

Godolphin answered 30/1, 2015 at 5:36 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.