What's the difference if one web page starts with
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="X-UA-Compatible" content="IE=edge">
and If page starts with
<!DOCTYPE html>
<html>
<head>
<!-- without X-UA-Compatible meta -->
If there is no difference, I suppose I can just ignore the X-UA-Compatible
meta header, since I just want it to be rendered in most standard mode in all IE versions.
Use
content=
"IE=edge,chrome=1"
Skip otherX-UA-Compatible
modesNo compatibility icon
The IE9 Address bar does not show up the Compatibility View button
and the page does not also show up a jumble of out-of-place menus, images, and text boxes.
Features
This meta tag is required to enable
javascript::JSON.parse()
on IE8(even when
<!DOCTYPE html>
is present)Correctness
Rendering/Execution of modern HTML/CSS/JavaScript is more valid (nicer).
Performance
The Trident rendering engine should run faster in its edge mode.
Usage
In your HTML
IE=edge
means IE should use the latest (edge) version of its rendering enginechrome=1
means IE should use the Chrome rendering engine if installedOr better in the configuration of your web server:
(see also the RiaD's answer)
Apache as proposed by pixeline
Nginx as proposed by Stef Pause
Varnish proxy as proposed by Lucas Riutzel
IIS (since v7)
Microsoft recommends Edge mode since IE11
As noticed by Lynda (see comments), the Compatibility changes in IE11 recommends Edge mode:
But the position of Microsoft was not clear. Another MSDN page did not recommend Edge mode:
Instead, Microsoft recommended using
<!DOCTYPE html>
:As Ricardo explains (in the comments below) any DOCTYPE (HTML4, XHTML1...) can be used to trigger Standards Mode, not only HTML5's DOCTYPE. The important thing is to always have a DOCTYPE in the page.
Clara Onager has even noticed in an older version of Specifying legacy document modes:
It is so confusing that Usman Y thought Clara Onager was speaking about:
Well... In the rest of this answer I give more explanations why using
content="IE=edge,chrome=1"
is a good practice in production.History
For many years (2000 to 2008), IE market share was more than 80%. And IE v6 was considered as a de facto standard (80% to 97% market share in 2003, 2004, 2005 and 2006 for IE6 only, more market share with all IE versions).
As IE6 was not respecting Web standards, developers had to test their website using IE6. That situation was great for Microsoft (MS) as web developers had to buy MS products (e.g. IE cannot be used without buying Windows), and it was more profit-making to stay non-compliant (i.e. Microsoft wanted to become the standard excluding other companies).
Therefore many many sites were IE6 compliant only, and as IE was not compliant with web standard, all these web sites was not well rendered on standards compliant browsers. Even worse, many sites required only IE.
However, at this time, Mozilla started Firefox development respecting as much as possible all the web standards (other browser were implemented to render pages as done by IE6). As more and more web developers wanted to use the new web standards features, more and more websites were more supported by Firefox than IE.
When IE market sharing was decreasing, MS realized staying standard incompatible was not a good idea. Therefore MS started to release new IE version (IE8/IE9/IE10) respecting more and more the web standards.
The web-incompatible issue
But the issue is all the websites designed for IE6: Microsoft could not release new IE versions incompatible with these old IE6-designed websites. Instead of deducing the IE version a website has been designed, MS requested developers to add extra data (
X-UA-Compatible
) in their pages.IE6 is still used in 2016
Nowadays, IE6 is still used (0.7% in 2016) (4.5% in January 2014), and some internet websites are still IE6-only-compliant. Some intranet website/applications are tested using IE6. Some intranet website are 100% functional only on IE6. These companies/departments prefer to postpone the migration cost: other priorities, nobody no longer knows how the website/application has been implemented, the owner of the legacy website/application went bankrupt...
China represents 50% of IE6 usage in 2013, but it may change in the next years as Chinese Linux distribution is being broadcast.
Be confident with your web skills
If you (try to) respect web standard, you can simply always use
http-equiv="X-UA-Compatible" content="IE=edge,chrome=1"
. To keep compatibility with old browsers, just avoid using latest web features: use the subset supported by the oldest browser you want to support. Or If you want to go further, you may adopt concepts as Graceful degradation, Progressive enhancement and Unobtrusive JavaScript. (You may also be pleased to read What should a web developer consider?.)Do do not care about the best IE version rendering: this is not your job as browsers have to be compliant with web standards. If your site is standard compliant and use moderately latest features, therefore browsers have to be compliant with your website.
Moreover, as there are many campaigns to kill IE6 (IE6 no more, MS campaign), nowadays you may avoid wasting time with IE testing!
Personal IE6 experience
In 2009-2012, I worked for a company using IE6 as the official single browser allowed. I had to implement an intranet website for IE6 only. I decided to respect web standard but using the IE6-capable subset (HTML/CSS/JS).
It was hard, but when the company switched to IE8, the website was still well rendered because I had used Firefox and firebug to check the web-standard compatibility ;)
if you use your website in the same network as the server IE likes to switch to compability mode despite DOCTYPE.
Adding
meta http-equiv="X-UA-Compatible" content="IE=Edge"
disables this unwanted behaviour.I think this diagram from Microsoft explains all. In order to tell IE how to render the content, !DOCTYPE has to work with X-UA-Compatible meta tag. !DOCTYPE by itself has no affect on changing IE Document Mode.
http://ie.microsoft.com/testdrive/ieblog/2010/Mar/02_HowIE8DeterminesDocumentMode_3.png
Just for completeness, you don't actually have to add it to your HTML (which is unknown http-equiv in HTML5)
Do this and never look back (first example for apache, second for nginx)
Just one sentence to say Instruct Internet Explorer to use its latest rendering engine
This is LITERALLY 1 google query away, but here goes:
http://msdn.microsoft.com/en-us/library/jj676915(v=vs.85).aspx
Also among the search results is: