X-UA-Compatible and Internet Explorer 9

Anyone who has done a bit of web development knows that getting a website to render the same in a bunch of different browsers, and different versions of the same browser can be difficult.

The firm I work for recently rolled out a new website. We hired a company to do the branding, design, and even hosting of the site. The results were awesome. Unfortunately, we ran into a situation with some of our computers (and some of our clients’ computers) in which Internet Explorer 9 would insist on rendering the page in compatibility view.

Microsoft’s suggested fix is to add the following tag in your HTML <head> section:

That works great, most of the time. However, for some reason, IE9 would just flat out ignore this tag on our website.

The solution was to add it to the HTTP Response Header. This can be done a variety of ways. On one of my websites, running Apache, I placed the following in the site’s config. This can be done with a .htaccess file, or in the configuration for the site.

If your site runs off of PHP, you could even use the PHP header() function to accomplish the same.

Moving this to the HTTP response headers appears to be more reliable and consistent than adding it as a <meta> tag in your HTML.