Force Internet Explorer 9 to use IE 9 Mode

Johnny Oshika picture Johnny Oshika · Feb 7, 2012 · Viewed 54k times · Source

I'm using the HTML5 doctype with X-UA-Compatible meta tag near the top:

<!DOCTYPE html>
<!--[if lt IE 7]> <html lang="en-us" class="ie6"> <![endif]-->
<!--[if IE 7]>    <html lang="en-us" class="ie7"> <![endif]-->
<!--[if IE 8]>    <html lang="en-us" class="ie8"> <![endif]-->
<!--[if gt IE 8]><!--> <html lang="en-us"> <!--<![endif]-->
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    ...

But Internet Explorer 9 for some users is rendering the page in compatibility view. I suspect it's because they have the "Display all websites in Compatibility View" setting turned on. Is there a way to force IE9 to use IE9 Browser and Document Mode?

Answer

Johnny Oshika picture Johnny Oshika · Feb 7, 2012

It turns out that the solution is to set X-UA-Compatible in the HTTP header and not in the HTML:

 X-UA-Compatible: IE=edge,chrome=1

This will force Internet Explorer to use the latest rendering engine, even if "Display all websites in Compatibility View" is turned on.