Search code examples
internet-explorerinternet-explorer-9quirks-mode

How do I get IE9 to use standards compliant mode when developing on localhost?


According to MSDN, all I need to force standards compliant mode is to include the HTML 5 doctype:

http://msdn.microsoft.com/en-us/library/gg699338%28v=vs.85%29.aspx

And it works when the markup is served remotely. The problem is when I take identical markup and serve it up from an apache server running locally. IE9 defaults to quirks mode, and the compatibility view button goes away.

I do a lot of development locally, and it defeats the purpose if I can only test my code in IE when it's served remotely. Thanks in advance.


Solution

  • Try adding this:

    <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN"
    "http://www.w3.org/TR/html4/strict.dtd">
    

    At the top of your page. I'm not sure if that will work locally if the other you tried didn't... but it's worth a go.