Foreword:

No way. I’m NOT writing this article.

Seriously! There is no way I’m going to do this!

You’ve kidnapped my mother? Nope. Still not doing it.

You’ll take away my browser? Erp…Fine. But I won’t like it.

Seriously, there is one tiny thing that I really love about IE: conditional comments. Admittedly, their main function is to make it possible for me to fix the piles of other problems IE (Internet Explorer) causes, but I nonetheless find them to be really fantastic. In fact, I wish that every browser had its own version of conditional comments.

The fact is that all rendering engines are different. Some of them are similar enough that you can generally get away with the same valid code and CSS (Cascading Style Sheets) – but they won’t behave quite the same. And this isn’t going to change. As close to the standards any engine gets, there will always be differences of interpretation. But when Internet Explorer screws with me, I have an easy way to deal with it:


<!--[if lt IE 7]><style type="text/css">@import "ielt7.css";</style>< ![endif]-->

Nice and simple: IE makes a drop by my conditional makeup counter, fixes itself up, and goes along for its business meeting with my site visitors. (I’m assuming it’s having business meetings; if it’s having dates, I don’t really want to know.)

But what do you do if you’ve got a bug in Opera, for example? They’re relatively rare; but this just makes them more difficult to deal with.

You can use hacks, of course. There are a lot of them, and some of them are designed for passing specific styles to Opera or preventing Opera from seeing them.

But I don’t like using hacks. I used to use them, but have lately found that using conditional comments is much more convenient.

You can use JavaScript browser sniffing, as well. Again – it’s a method I really don’t like. It’s fussy, it’s ineffective – and it doesn’t work at all if you’ve got a user with JavaScript disabled. Javascript browser sniffing is easy – it’s extremely simple to find out what browser your visitor is using. Unfortunately, it’s more complicated to make use of that information. You have to write fairly complex code in order to separately determine the browser and the version and deliver an appropriate stylesheet.

I think that a feature like conditional comments in each browser could make life much easier for the developer. It’s the one small feature in IE that I’m really thankful for.