3

So in my interweb travels of evaluating other programmer's CSS I've noticed a bunch of people using the underscore or asterisk hack that is vendor specific to IE browsers for debugging purposes though W3C does not parse this as valid CSS.

I personally prefer comment conditionals where you can at least defer to IE specific CSS that is valid but I guess the only issue with that would be addition of extra CSS.

So I'm curious about a consensus of what you prefer and the positive or negative implications of each method.

Comment conditonals or IE vendor specific hacks?

PS - Honestly this should be titled do you support IE layout or not :-)

TylerH
  • 20,799
  • 66
  • 75
  • 101
ectype
  • 14,865
  • 5
  • 21
  • 28

2 Answers2

3

Conditional style sheets are the way to go. The word hack itself implies that you're doing something that you shouldn't. But a few short words on both:

Conditional style sheets

  • (+) Cleaner CSS code
  • (+) Easier to manage
  • (+)Easiey to understand for other developers
  • (+) CSS validates
  • (-)More CSS files (thus more server load)

Hacks

  • (+) Faster (possibly)
  • (-) Messes up your CSS
  • (-) CSS doesn't validate
  • (-) Very unclear for other developers (especially non-experienced one's)
  • (-) Could cause problems with newer versions of IE
Damien
  • 1,219
  • 13
  • 23
1

I prefer the conditional comments, because it makes your page still validate. I could imagine, however, that you use the vendor hacks, because you won't need an extra css file, saving a request per page loaded (if not for caching, of course). Then again, the css files are cached, and if you use your conditionals wisely, you can make a separate file per IE version, copying hacks if they are needed for more than one version. That way, you need at most one extra css per page, which is then cached as well, thus minimizing the extra load.

GolezTrol
  • 114,394
  • 18
  • 182
  • 210
  • I usually put the IE styles inline (in a style element), as since they're often only a couple of lines it's not worth having an entire separate CSS file. – JAL Jan 04 '11 at 18:14
  • @Sombrero - I like that chain of thought, however that creates noise in the source code (which I like to keep as clean as possible). – Damien Jan 07 '11 at 08:00
  • @Damien on the other hand, I'd like to avoid having 100 one-line CSS files in my static directory, as well as the needless overhead of an additional HTTP request. – JAL Jan 08 '11 at 19:44
  • As I said, you can have one css per IE version. That will cause only one extra request, and well, how many versions do you need to support? IE6 and 7? For 8 you probably won't even need a separate CSS. If you need so many exceptions, you're probably doing something wrong. I've seen quite large and complex websites that only need a handful of hacks for IE6. – GolezTrol Jan 09 '11 at 10:27