If you are using the X-UA-Compatible meta tag, then you’ll probably run into this error when attempting HTML5 validation at the W3C. It’s common to use X-UA-Compatible to set Internet Explorer to edge mode (forcing the latest rendering engine), and to enable Google Chrome Frame for visitors with that IE plugin.

To make the validation error go away (perhaps it is your only remaining error?), the meta tag can be removed and the value can be sent through the HTTP headers instead. Depending on the web technology you’re using and your server settings, this can be done in different ways, and I thought it’d be a good idea to collect the syntax in one place.

Set HTTP Header with PHP

If you are working with a PHP framework or template, you can set these with the header function. Since I was already setting a PHP header for Content-Type, as suggested by Google PageSpeed Tools, this was simple for me to add another one:

header('X-UA-Compatible: IE=edge,chrome=1');

Using the .htaccess File

Make sure you have the mod_headers module enabled in Apache.

Header set X-UA-Compatible "IE=Edge,chrome=1"

With IIS web.config

Syntax provided by GCF Developer Guide.

With C#

I don’t typically use C#, but this was mentioned by a StackOverflow user and worth including:

Response.AppendHeader("X-UA-Compatible", "IE=edge,chrome=1");

If you would like to check that these are working properly, I would recommend testing the page with a header check tool such as this one.

References and More Info:

Comments on this Article

  1. Nick says:

    Thanks the php version worked great!

    • Vincent Browning says:

      can somebody tell me where I should put the php version to solve this error? My .htaccess file is not visible on the server.

  2. Luis says:

    Maravilhoso! Consegui corrigir um layout no WordPress com esta técnica.

    Muito obrigado!

  3. Vincent Browning says:

    Hi Guys,

    I am trying to get rid of the Bad Balue X-UA etc etc

    Where do I put this code? header(‘X-UA-Compatible: IE=edge,chrome=1′);

    In the header page and if so where in the header.php page.

    I am using wordpress and woo theme mystyle. It is the only error showing at present on validation.

    All help appreciated.

    Thanks

    Vincent

    • Josh says:

      Put it within opening and closing PHP tags at the very top of your theme’s header.php. Basically, set the HTTP header values before anything is printed on the page (HTML, whitespace).

  4. Lars says:

    The PHP Version works perfect. Thanks a lot! :)

  5. Cristian Alarcón says:

    Thanks :D very useful!

  6. guter-webhoster.de says:

    What does the header actually do?

    I do not know where to send the header within my wordpress code to ensure the content has not been already sent.

    • Josh says:

      HTTP headers are hidden info that is sent with every HTTP request (the requested page, the client browser, etc). The header.php file is first included part of most WordPress templates, and is located within your theme folder: /wp-content/themes/yourthemename/header.php
      You would put the line of PHP code within the first set of PHP tags.

Leave a Reply

You can use the <pre> tag to post a block of code, or <code> to highlight code within text.

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>