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?
As JohnnyO says it has to be sent as a header. In PHP add this (before any other output is sent):
In Wordpress this would probably be best if you put it as the very first line in your
header.php
file as long as you don't have any output (or errors) before that file is rendered it should work.If you have errors being output to the browser you may want to tell errors to be logged only and not output to the screen by adding something like this to your application:
In Wordpress that could be added near the top of the
wp-config.php
file.If you have caching enabled with something like WP SuperCache or W3 Total Cache all bets are off regarding the behavior of your site - you'll need to do some searching for how to add extra headers with your caching plugin.