HTML5 doctype putting IE9 into quirks mode?

86,894

Solution 1

Placing:

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

in the <head> tag should do it.

Solution 2

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.

Solution 3

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" />

Solution 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.

Share:
86,894

Related videos on Youtube

Abhishek
Author by

Abhishek

User Experience advocate, Web wizard and Interface design nerd. Guitarist, Writer, PC (MasterRace) Gamer, Household comedian, Indulgence moderation consultant. Weapon of choice - SublimeText Weapon mod - Sublimelinter Primary Ammo - HTML5, JavaScript (vanilla), CSS3 Secondary Ammo - AJAX, PHP I don't work, I play. I don't do things quick, I do them well.

Updated on January 30, 2020

Comments

  • Abhishek
    Abhishek about 4 years

    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?

    • Abhishek
      Abhishek almost 13 years
      @EricLaw - Huh? I don't follow...
    • EricLaw
      EricLaw almost 13 years
      What is the URL of your page that reproduces this problem.
    • Abhishek
      Abhishek almost 13 years
      Its an internal testing page I'm using... But nvm, @David_Wick already answered the question... :-)
    • Raedwald
      Raedwald about 9 years
  • Abhishek
    Abhishek almost 13 years
    Yup, that did the trick... Could you please explain this a little bit for me?
  • reisio
    reisio almost 12 years
    @Abhishek: meta elements need not be explicitly closed in HTML5 (and historically against older HTML specs closing it would in fact be invalid).
  • reisio
    reisio almost 12 years
    @frumbert: except that case has comments before the doctype declaration, so no.
  • frumbert
    frumbert almost 12 years
    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.
  • reisio
    reisio almost 12 years
    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).
  • Shauna
    Shauna over 11 years
    @reisio - If you look at the history, you'll see that he had originally left off the closing bracket (>).
  • DeadlyChambers
    DeadlyChambers almost 10 years
    Does it have to be the first or only meta tag? Because it is in there and still defaults to quirks mode.
  • Paolo Mioni
    Paolo Mioni over 9 years
    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.