67

When I open a webpage in IE9 with DOCTYPE as

<!DOCTYPE html>

It opens Document Mode as IE7 standards.

I need default IE9 standards on opening the page.

How to correct this document mode problem?

A screenshot of how it comes in IE browser developer tool

enter image description here

Justin John
  • 9,223
  • 14
  • 70
  • 129

7 Answers7

99

Try this answer: https://stackoverflow.com/a/13524518/1679310.

Summary, give the IE browser more information in the meta tag:

<!DOCTYPE html>
<html>
  <head>
    <title>My Web</title>
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />

Edit Note: As Olly Hodgson mentioned, the proper option is IE=edge, as currently stated in the above snippet. Below is the original, also working version:

   <meta http-equiv="X-UA-Compatible" content="IE=100" />
Community
  • 1
  • 1
Radim Köhler
  • 122,561
  • 47
  • 239
  • 335
  • You solution works fine. How does this works when `IE10` as my browser? – Justin John Dec 19 '12 at 10:18
  • 2
    just one note, that meta really must be the first after the title. IE9 works with IE=100. I think that IE10 will work with IE=100. But I did not tested yet ;( – Radim Köhler Dec 19 '12 at 10:21
  • 20
    Gah! Set it to `content="IE=edge"` to ensure it always uses the latest version of IE! – Olly Hodgson Dec 19 '12 at 10:35
  • @OllyHodgson Which would be better choice either `"IE=edge"` or `"IE=100"`? – Justin John Dec 19 '12 at 10:55
  • 4
    `IE=edge` is Microsoft's way of making sure you always target the latest version, so I'd go with that. – Olly Hodgson Dec 19 '12 at 14:40
  • @OllyHodgson Both solutions `IE=100` and `IE=edge` works fine for me. I would like to add your answer `content="IE=edge"` as separate answer instead of given comment. Can you do it in your end or Shall I do it? – Justin John Oct 06 '13 at 08:19
  • 1
    @JustinJohn I've changed the answer, with the proper settings – Radim Köhler Oct 06 '13 at 08:30
  • @RadimKöhler Thank you for your edit. I already suggested an edit in answer earlier, but the suggestion was rejected. That is why I suggested Olly to write a separate answer. – Justin John Oct 06 '13 at 16:13
  • But I don't have opinion to remove `IE=100` from answer, as it works fine too.. :) – Justin John Oct 06 '13 at 16:20
  • Done. I just wanted to move the more precise comment into the answer – Radim Köhler Oct 06 '13 at 16:32
  • 1
    Thanks @RadimKöhler. I believe all this is getting deprecated as of IE11 anyway (I *think* it'll still work, but ` ` will default to standards mode). See http://msdn.microsoft.com/en-us/library/ie/bg182625%28v=vs.85%29.aspx#docmode – Olly Hodgson Oct 07 '13 at 15:15
  • The problem with using IE=100 is that when IE101 comes out, your code will no longer be targeting the latest version. So, use IE=edge to always target the latest. – Christopher Thomas Nicodemus Oct 15 '14 at 17:27
  • @ChristopherThomasNicodemus Thank you. I am always using `IE=edge` after reading this answer. Would IE survive in web until IE101 comes, unless a serious non-order IE version bump happens? :) – Justin John Oct 24 '14 at 14:42
36

There can be multiple reasons why it could be parsing the document under IE7 standard:

  1. The server is sending a X-UA-Compatible header for IE7 in the HTTP response of the document. Check the server response headers using a tool like Fiddler.
  2. The HTML document is setting a meta tag with the X-UA-Compatible property value for IE7.
  3. The page is being detected automatically by IE for opening in "Compatibility view". Note here that by default all intranet sites are viewed in "Compatibility view" in IE. Uncheck the checkbox "Display intranet sites in Compatibility view" under Tools -> Compatibility view settings in IE. The "Display all websites in Compatibility view" should be unchecked too.
  4. You used the Developer tools and explicitly set to view the page to render in "IE7 standards" mode. Note that this will only occur on a per client basis though.

Update 2016-01-28
As @Gordon pointed out in the comments below, another reason can be that the network administrator has set the site for compatibility view as a Group Policy on the network.
The only resolution in that case is to contact the network administrator to remove the site from the Group Policy. See HTML1203 here.

Tanzeel Kazi
  • 3,797
  • 1
  • 17
  • 22
  • I need to force IE9 or greater as standards, my webpage doesn't supports `IE < 9` as it is using HTML5. – Justin John Dec 19 '12 at 10:15
  • @JustinJohn Have checked "Compatibility view" settings in IE as I stated? Is it an intranet site? If the page is online can you post the URL? – Tanzeel Kazi Dec 19 '12 at 10:18
  • 7
    Dang, it was number 3 for me. Thanks Tanzeel, didn't know that setting was there! – LowTide Jan 31 '14 at 18:50
  • 1
    Number 3 is what fixed the issue that brought me to this page! I was getting all sorts of rendering problems for all internal web apps. – bspkrs Jan 14 '15 at 15:26
  • Excellent... same here.. Number 3 did the trick for me as well. I already had IE=edge.. but was not getting any clue of why it was using IE 7 as default. Compatibility view for intranet sites was the reason.. Unticked.. and that worked. – Nirman Aug 28 '15 at 06:24
  • 1
    It can also be set with a group policy on the network - see [HTML1203 here](https://msdn.microsoft.com/en-us/library/hh180764(v=vs.85).aspx). Apparently nothing you can do in that case. – Gordon Jan 25 '16 at 20:25
  • Good call @Gordon , I'll add that as an update to the answer. – Tanzeel Kazi Jan 28 '16 at 23:22
7

You can set this in the web.config as well.

<system.webServer>
    <httpProtocol>
        <customHeaders>
            <clear />
            <add name="X-UA-Compatible" value="IE=edge" />
        </customHeaders>
    </httpProtocol>
Don Rolling
  • 2,301
  • 4
  • 30
  • 27
  • 1
    Putting it here has always been much more reliable for me, the meta tag is very picky and simply having it right at the top of the head (or after title) does not always work. – 4imble Jan 13 '15 at 15:42
3

Does your page contain the meta tag for forcing IE7?

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

this will force the page to use IE7 compatibility.

Qpirate
  • 2,078
  • 1
  • 29
  • 41
2

Just wanted to share that if your web server is Apache2 you could set the Response header like below in your VirtualHost configuration which will also resolve the issue.

Header set X-UA-Compatible "IE=edge"
Dev Blanked
  • 8,555
  • 3
  • 26
  • 32
1

The issue appears to be specific to the combination of IE9 and compatibility mode. For us, we cannot disable compatibility mode since it is a SharePoint 2013 site and IE11 must run in compatibility mode to edit pages, but IE9 was behaving as you are showing. Setting the X-UA-Compatible to "IE=edge" in a meta tag did fix our issue, although setting the value to IE=10 did not affect our behavior. We also have the same doctype.

Matt Connolly
  • 1,233
  • 2
  • 13
  • 20
1

If your project is ASP.NET MVC, make sure that you add the:

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

tag into your Layout (template) page. I just spent two hours debugging and tweaking, only to realize that I had only added that meta tag into my child pages. As soon as I added it to my layout page, the browser loaded in EDGE mode perfectly.

Jason Marsell
  • 1,752
  • 2
  • 19
  • 10