Contents

The X-UA-Compatible

One of my post, "Super Simple is still not HTML5 valid," has constantly been found on search engine since it got published and I felt very annoyed1 and sorry for those people who had visited that post. They wouldn't find the answer they want, which is a solution to get rid of this error reported by W3C Validator:

X-UA-Compatible

The checked HTML source is from Blogger's Super Simple template, since it's an official template, which possibly most of Blogger bloggers would have such invalid code in their page source. I wrote my own HTML5 template, this blog doesn't have such error, though still has a lot of other invalid codes which mostly contributed (injected) by Blogger.

So, the keyword (non-valid/standard pragma directive) here is "X-UA-Compatible." It is made by Microsoft for their Internet Explorer, Version 8 to be precise, which I would like to call it as the most complicated and confusing web browser2 ever made. The author, Mark Pilgrim, of "Dive into HTML5," has written about this on WHATWG blog:

The idea of version identifiers has been hashed and rehashed throughout the 5+ year process of defining HTML 5. Most notably, Microsoft proposed a version identif[i]er shortly after the W3C HTML Working Group reformed around HTML 5. Their proposal generated much discussion, but was not ultimately adopted. Several months later, Microsoft shipped Internet Explorer 8 with a "feature" called X-UA-Compatible, which serves as a kind of IE-specific version identifier. I am personally not a fan of this approach, in part because [PNG] it adds a lot of complexity for web developers who want to figure out why the still-dominant browser doesn't render their content according to standards.

(emphasis added)

The fact is X-UA-Compatible is not, I emphasize it is NOT a standard. Currently, only five pragma directives and addition(s) are valid. Of course, Microsoft has tried to purpose, but then I read:

4.2.5.4 Other pragma directives

Extensions to the predefined set of pragma directives may, under certain conditions, be registered in the WHATWG Wiki PragmaExtensions page. [WHATWGWIKI]

Such extensions must use a name that is identical to an HTTP header registered in the Permanent Message Header Field Registry, and must have behavior identical to that described for the HTTP header. [IANAPERMHEADERS]

(emphasis added)

They have to get registered on IANA's Permanent Message Header Field Names first. Which also mean, X-UA-Compatible is not a standard HTTP header, well, that's what X- prefix for.

The Only Solution

So, the only way to get rid of that error message is to set up your web server to send such HTTP header. But mind you again, it's not a standard and not even a common non-standard header. If you are an open and standard person, I strongly recommend you just forget this X-UA-Compatible, live with it or kick it out of your HTML source.

Once you have it sent using HTTP header, you can remove the naughty code from HTML source.

IE conditional comment trick?

At first, I thought we can use this dirty thing

<!--[if ie]><meta content='IE=8' http-equiv='X-UA-Compatible'/><![endif]-->

, once again made by Microsoft. So, at least, we wouldn't see the error message and it might still work for IE. It's a valid HTML comment and W3C Validator doesn't report that anymore.

However, it is only sort of working but not taking effective for mode setting in IE8, as I observed using IE's developer tool. It means IE recognized that meta tag, the tag did show up in DOM tree, but specifying document compatibility doesn't take effective. The reason could be this:

The X-UA-compatible header is not case sensitive; however, it must appear in the Web page's header (the HEAD section) before all other elements, except for the title element and other meta elements.

It's not appeared before other elements, in fact, it's wrapped by HTML comment. Nice job, Microsoft, is there a security issue for the mighty IE conditional comment trick not working? Or just doing complicating once again?

So?

Please don't give a dime to non-standard. Unfortunately, even Google does and use it. Now, two companies use it, but it's still mainly for IE since Chrome Frame is for IE. The X-UA-Compatible is brought up solely for one specific web browser in my opinion.

Do I really care about any about it, nope. I wrote this post because I don't like people visiting my blog and finding nothing useful, not even a slightly related information about what they are looking for. That really sucks, I could relate. If you have anything, please feel free to add or to correct me. I am sure stuff I wrote above might have some serious flaws.

Anyway, someday, we might see UA-Compatible or User-Agent-Compatible, but I would prefer call it UA-Complication. (I would be 200% thumbs-up for the last one since Microsoft is the only one needs to use it)


  1. As of writing this post, within last 30 days, 207 Pageviews, 195 Unique Views, 00:03:31 Time on Page, 92.19% Bounce Rate, 91.79% % Exit. Sorry for those people, who wasted 3:31 minutes in their life. 

  2. I call this Hell IE8! You can make it more complicated, Microsoft!