56

I have this in the <head>:

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

It will force the latest rendering mode for IE, but is Compatibility Mode considered the last one?

I mean, for example: using this code with IE8, it will force it to use IE8 or IE8 Compatibility Mode?

naXa stands with Ukraine
  • 35,493
  • 19
  • 190
  • 259
Jonathan
  • 8,676
  • 20
  • 71
  • 101
  • From MSDN: "Because edge mode documents display webpages using the highest mode available to the version of Internet Explorer used to view them, it is recommended that you should only use this document mode for testing purposes only. Do not use it for production uses." (http://msdn.microsoft.com/en-us/library/cc288325(v=vs.85).aspx) – Steven Berkovitz Apr 30 '12 at 22:32

4 Answers4

64

That tag will try to force the browser to use the latest rendering mode the browser supports. It will not trigger Compatibility mode.

Note that the tag has to be the first tag in the head or it will not work. This fact favors using HTTP headers if possible as the order in the HTTP headers does not matter.

If the browser stills ends up in Compatibility mode when you use a header or the meta tag one of these things is likely the cause:

  • you are missing a sane doctype
  • the browser has been set to always use compatibility mode
  • the site is hosted on an "intranet site" and the default setting for intranet sites is set

Changing the browsers Compatibility View settings

Microsoft considers at least 192.168.x.x to be on a "Intranet site". The default for intranet sites in IE8/IE9 is to use compatibility mode. That's a huge issue for many business applications as the programmer CANNOT override this option even with this meta tag. ("Display intranet sites in Compatitiblity View" is not overridable by meta tag or http header - the browser is in complete control of compatibility view in this case)

Compatibility View Settings

Always add this meta tag or an http header?

One more good thing about using this meta tag is that the "compatibilty view" icon is removed from the address bar of the browser. At least your users can then not decide the render mode using that button.

oldwizard
  • 5,012
  • 2
  • 31
  • 32
  • 2
    According to this http://ie.microsoft.com/testdrive/ieblog/2010/Mar/02_HowIE8DeterminesDocumentMode_3.png it should be overridable by a header. – Kees C. Bakker Oct 29 '12 at 10:14
  • I've tried HTTP headers as well, if the page was served from an "intranet site" the header did nothing to remove Compatibility Mode if the "Display intranet sites in Compatibility View" checkbox is checked. If you get it to work with a header I would very much like to know how you did it to improve things over here as well. :) – oldwizard Nov 20 '12 at 22:49
  • I've created an Asp.Net dll to fix it for an international client that was on the MS list. What language do you use? – Kees C. Bakker Nov 21 '12 at 08:37
  • Nice, and it works if the server is hosted in the 192.168.x.x range? C# or vb doesn't matter. – oldwizard Nov 22 '12 at 12:23
  • The third bullet is incorrect. I am using IE8 with "Intranet sites in compatibility mode" enabled, but the meta tag is overriding that setting properly. – Justin Skiles Feb 07 '13 at 18:24
  • Are you hosting the site on 192.168.x.x. range? Localhost/127.0.0.1 is not considered to be intranet, and is not forced to run in compatibility mode with that checkbox. – oldwizard Feb 15 '13 at 11:27
  • 1
    Not overridable? One more reason to absolutely despise IE. – Craig Tullis Sep 18 '14 at 21:01
2

Even if you have unchecked the "Display intranet sites in Compatibility View" option, and have the X-UA-Compatible in your response headers, there is another reason why your browser might default to "Compatibility View" anyways - your Group Policy. Look at your console for the following message:

HTML1203: xxx.xxx has been configured to run in Compatibility View through Group Policy.

Where xxx.xxx is the domain for your site (i.e. test.com). If you see this then the group policy for your domain is set so that any site ending in test.com will automatically render in Compatibility mode regardless of doctype, headers, etc.

For more information, please see the following link (explains the html codes): http://msdn.microsoft.com/en-us/library/ie/hh180764(v=vs.85).aspx

rshadman
  • 405
  • 5
  • 8
  • Through testing I've found that the Compatibility View Group Policy setting forces Internet Explorer to use "Mozilla/4.0 (compatible; MSIE 7.0;..." for the user agent of the request, but the X-UA-Compatible IE=Edge meta tag will cause the page to render with the actual user agent of IE. So any server side browser detection will detect IE 7, while client side browser detection will detect the actual version of IE. – Gabby Paolucci Mar 05 '14 at 21:45
0

I'm not an expert but by trial and error:

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

solved the problem for me. I used this on websites and webapps and it stopped IE8 from going into compatibility mode, and displayed as 'standard' in IE10 and IE11.

MelanieMenard
  • 13
  • 1
  • 3
-3

What is the point of using the Edge keyword alone? I mean, if you want IE to use the most recent rendering engine, then just drop the whole meta tag.

Otherwise, it should look something like that (that would make IE8 behave like IE7 and IE9 and newer will work as usual) :

<meta http-equiv="X-UA-Compatible" content="IE=EmulateIE7, IE=Edge" />
unclenorton
  • 1,605
  • 11
  • 19
  • 1
    Would you care to clarify that of link to something describing this? In cases I've seen, you either specify IE=8 (or some other number) requesting a behaviour in IE close to that of IE8, or you specify IE=edge to request the native behaviour of the actual version used in IE. – Rasmus Kaj Nov 09 '11 at 15:52
  • @Rasmus, the point is, you actually *can* specify multiple modes. Here is the related discussion (more links inside): http://stackoverflow.com/questions/3413629/emulate-ie7-for-ie8-but-not-for-ie9-using-x-ua-compatible – unclenorton Nov 09 '11 at 17:34
  • 3
    Edge is used so that the user cant enable compatibility mode. It's very helpful in normalizing IE's behavior. Compatibility mode can break certain things (like layout or javascript) and Edge can help you avoid this all together. If you don't specify the meta tag the user can chose compatibility mode and can break your page – derickito Nov 14 '12 at 22:49
  • Not sure about the down-votes. unclenton is accurate and his comments explains his point very well. My use case: I want IE8 to render under IE7 but I don't want to force IE9 and 10 to do the same. – donohoe Feb 22 '13 at 21:20
  • Downvotes are likely due to what derickito said: "Edge is used so that the user cant enable compatibility mode". It's an important feature so that users don't accidently break your page by clicking that stupid compatibility button in the address bar by mistake. – oldwizard Mar 08 '13 at 10:09
  • 1
    IE displays intranet sites using IE7 document mode. `IE=Edge` (or other settings) overcomes it. – Sam Mar 20 '13 at 00:01
  • "I mean, if you want IE to use the most recent rendering engine, then just drop the whole meta tag." In my case, the clients server have some headers that make IE use IE7 as document mode. Therefore edge alone, is useful. – Qar May 17 '13 at 14:33