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?

Jeff
  • 11,233
  • 10
  • 44
  • 85
Abhishek
  • 3,880
  • 10
  • 36
  • 51

5 Answers5

134

Placing:

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

in the <head> tag should do it.

Tim Cooper
  • 144,163
  • 35
  • 302
  • 261
David Wick
  • 6,877
  • 2
  • 33
  • 36
  • 1
    Yup, that did the trick... Could you please explain this a little bit for me? – Abhishek Jun 30 '11 at 04:15
  • 8
    @Abhishek: meta elements need not be explicitly closed in HTML5 (and historically against older HTML specs closing it would in fact be invalid). – reisio May 23 '12 at 19:19
  • 4
    @reisio - If you look at the history, you'll see that he had originally left off the closing bracket (`>`). – Shauna Dec 04 '12 at 15:27
  • Does it have to be the first or only meta tag? Because it is in there and still defaults to quirks mode. – DeadlyChambers May 07 '14 at 15:29
  • 2
    I found out that putting this meta tag right after the tag will work, while having it at the bottom of might not work, probably due to other content interfering. – Paolo Mioni Jul 31 '14 at 09:18
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.

zuallauz
  • 4,258
  • 9
  • 40
  • 54
  • 1
    @frumbert: except that case has comments before the doctype declaration, so no. – reisio May 23 '12 at 19:30
  • 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. – frumbert May 24 '12 at 02:13
  • 2
    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). – reisio May 29 '12 at 00:35
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" />
Community
  • 1
  • 1
Ian Boyd
  • 220,884
  • 228
  • 805
  • 1,125
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.

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.