How to disable Compatibility View in IE
All you need is to force disable C.M. in IE - Just paste This code (in IE9 and under c.m. will be disabled):
<meta http-equiv="X-UA-Compatible" content="IE=9; IE=8; IE=7; IE=EDGE" />
Source: http://twigstechtips.blogspot.com/2010/03/css-ie8-meta-tag-to-disable.html
This should be enough to force an IE
user to drop compatibility mode in any IE
version:
<meta http-equiv="X-UA-Compatible" content="IE=EDGE" />
However, there are a couple of caveats one should be aware of:
- The meta tag above should be included as the very first tag under
<head>
. Only the<title>
tag may be placed above it.
If you don't do that, you'll get an error on IE9
Dev Tools: X-UA-Compatible META tag ignored because document mode is already finalized.
If you want this markup to validate, make sure you remember to close the
meta
tag with a/>
instead of just>
.Starting with
IE11
, edge mode is the preferred document mode. To support/enable that, use the HTML5 document type declaration<!doctype html>
.If you need to support webfonts on
IE7
, make sure you use<!DOCTYPE html>
. I've tested it and found that rendering webfonts onIE7
got pretty unreliable when using<!doctype html>
.
The use of Google Chrome Frame is popular, but unfortunately it's going to be dropped sometime this month, Jan. 2014.
<meta http-equiv="X-UA-Compatible" content="IE=EDGE,chrome=1">
Extensive related info here. The tip on using it as the first meta tag is on a previously mentioned source here, which has been updated.
<meta http-equiv="X-UA-Compatible" content="IE=8" />
should force your page to render in IE8 standards. The user may add the site to compatibility list but this tag will take precedence.
A quick way to check would be to load the page and type the following the address bar :
javascript:alert(navigator.userAgent)
If you see IE7 in the string, it is loading in compatibility mode, otherwise not.
If you're using ASP.NET MVC, I found Response.AddHeader("X-UA-Compatible", "IE=edge,chrome=1")
in a code block in _Layout to work quite well:
@Code
Response.AddHeader("X-UA-Compatible", "IE=edge,chrome=1")
End Code
<!DOCTYPE html>
everything else
The answer given by FelixFett worked for me. To reiterate:
<meta http-equiv="X-UA-Compatible" content="IE=11; IE=10; IE=9; IE=8; IE=7; IE=EDGE" />
I have it as the first 'meta' tag in my code. I added 10 and 11 as those are versions that are published now for Internet Explorer.
I would've just commented on his answer but I do not have a high enough reputation...