Why “<!–[if gt IE 6]>” is so bad…


if you are doing HTML you are certainly aware of what the line in the subject means.

Where it comes from:

Well, the internet (and if you want a part of it called “the web”) is a strange place. We all talk about standards but it took some reasonably time to really with more or less real standards. In the mean everybody including Microsoft saw things as a place to be innovative. This resulted in being more or less “standard” conform. The short story is it was necessary to adopt websites to different browser versions. We all hate it, we all get used to it.

One way of doing this was spreckling HTML (and JavaScript) around your websites with constructs like this in the subject line. It checks wether the version of the browser is greater than IE6 and does then some stuff to correct the rendering of the page. Very prominent is the shift one pixel thing (it always reminds me on “It’s just a jump to the left” of Rocky Horror Picture Show)

And now there is IE8:

IE8 comes in a standard conform mode! Hurray, we all should freak out… well, wait a second: There are this enormous amounts of constructs like the one in the subject line sprinkled all across the webcode. And we all know that 8 still is larger than 6 so the code will fire. But this time leading to a wrong rendering. So, while we still see that it is a move in the right direction we are all aware there will be a hickup first.

How to solve this?

Well, there is a mode in which IE8 “simulates” an IE7. You can switch your browser into this mode by having either a server header or a meta tag in your html code. You can find the details here http://msdn.microsoft.com/en-us/ie/default.aspx

The better way is to render conform to the standards but to be honest I do not expect to happen this throughout the whole web ever 😉 Yes, this might mean to touch your websites or to install an update for your CMS. But in the end it will be worth it…

Another lesson within this:

Using the clause if gt IE 6 means that while somebody wanted to react on IE 7 she or he actually reacted on IE 7,8,9,10… See the problem?? There was an implicit decision done for future versions…uh, bad habbit 😉



Skip to main content