Do It Right The First Time; Do Not Use Microsoft-Contrived Version Targeting

Bevan Rudge

on

December 8, 2008

Do It Right The First Time; Do Not Use Microsoft-Contrived Version Targeting

Microsoft announced in January that Internet Explorer 8 (IE8) would be standards-compliant, but only if you included a special meta tag or http header indicating that the page should be rendered in standards compliance mode. The uproar from the standards community led Microsoft to change the default behavior of IE8. Now IE8 will render all pages in standards mode by default, unless you specify otherwise with the X-UA-Compatible meta tag or http header. Interestingly, the Microsoft followers did not seem to feel short-changed as the standards advocates had. Perhaps they are not as passionate – or maybe they are used to succumbing to Microsoft's game-playing with software industry professionals. In any case, some bloggers still completely miss the point of standards, and are recommending you add the dreaded Microsoft-designed meta tag before IE8 is released. Websites that are built right the first time – for standards-compliant browsers first, then for browser-specific bugs in separate files – will likely work fine in IE8 with no or very little work. Most of the time, simply specifying that IE's CSS file is for only versions less than 8 will probably be sufficient. Microsoft's conditional comments are good for this. E.g.; <!--[if lt IE 8]><style type="text/css" media="all">@import "fix-ie7.css";</style><![endif]--> lt IE 8 (less than Internet Explorer 8) is the keyword that says that the HTML inside the conditional comment only applies to versions of IE with version numbers less than 8. There is also an lte and gte keyword for less than or equal to and greater than or equal to respectively. However these easily lead to errors in the version-specifications and are not recommended. The above snippet and the following variant for targeting IE6 are sufficient for almost all IE-version targeting purposes; <!--[if lt IE 7]><style type="text/css" media="all">@import "fix-ie6.css";</style><![endif]--> The Microsoft-contrived X-UA-Compatible approach will also 'fix' older websites so that they work in IE8, but with less features and less efficiently than by allowing IE8 to render the page in it's now-native standards mode. You also risk your website breaking completely if Microsoft breaks the IE7-rendering mode support in IE8 or future versions. In other words, sooner or later you will have to make your website standards-compliant anyway. Furthermore, the X-UA-Compatible approach effectively discourages compliance with web standards, which are what make the internet possible, and create a healthy industry for the web workers that build the internet and websites. Don't forget this important point.

Share it!