Andrew Jaswa

Un-Conditional

Conditional comments. Browser hacks. You might like them, but I don’t.

Why don’t I? Mainly because they present a unique set of instructions to one or many browsers but usually not to all of them at the same time. So what big deal? Right? I mean we’ve done that for years why, should we stop coding and presenting things for a particular browser?

Browser Hacks

You can do some pretty neat things with sending one set of instructions to one browser and another set to a different one. Take a look at the CSS Zen Garden design Gemination. It is presented as one design to IE and another design to the other major browsers. This uses CSS to set styles for one browser then over writes them for another browser. Now while this isn’t conditional comments, it still follows the same idea: one set of instructions is being sent to one browser and a different set for another.

Conditional Comments

Conditional comments are Microsoft’s way to target different versions of Internet Explorer. Jens Meiert presents rather strong arguments as to why conditional comments are bad. I won’t get into that side of things he does, but there is another side. This other side is what I call conditional CSS.

Conditional CSS

Do you ever run into a website that requires you to use a specific browser? I’m talking recently, not 10 years ago. Well I have… It wasn’t pretty. The web has grown up lately (in case you haven’t noticed) and browsers are getting better at rendering things. There is no longer a need for Internet Explorer or Firefox only websites.

Conditional Comments are mainly used for CSS. Browser hacks are based on the differences in the support of CSS by a specific rendering engine. A combination of conditional comments and browsers hacks is what I like to call conditional CSS (cCSS). cCSS is a way for you to deliver different instructions to different browsers. You shouldn’t ever need to do this. Browsers are now at a point where they’ve started to render things very closely the same. If you continue to use cCSS at some point in time it will begin to break sites that you’ve built in specific browsers.

Pixel perfection

One reason that people use cCSS is to make websites looks exactly the same in all the major browsers. Well they don’t need to be. I realize that this might be in contradiction from what I was just saying but hear me out. By not using cCSS you’ve ensured that your site will be more future compatible than ones with hacks. You’ve also removed the need for extra CSS that adds file weight. Think about this: do you want to download an extra CSS file for each browser only if you are using just one?

cCSS comes down to this: it’s an un-elegant way to produce websites. You should be able to build out sites with very little hacks and conditions. Be un-conditional. Take out your cCSS and start building better more standard websites.

June 2, 2008
I build crappy websites every day!
Andrew Jaswa