What are pros and cons
if i make 4 different css?
- main.css
- IE7.css ( in conditional comments)
- IE8.css ( in conditional comments)
- IE6.css ( in conditional comments)
OR
1 css file for all
- main.css + including hack for IE6 + IE 7 + IE8(if needed)
What are pros and cons
if i make 4 different css?
OR
1 css file for all
The con against having different style sheets is that you'll have one more HTTP request. I find that totally negligeable against the pros, though:
Cleaner code structure
No hacks = no reliance on broken / undocumented behaviour
Much easier to maintain for people joining the project later
New versions can be added easily (though hopefully, that won't be necessary for IE9 any more)
Pros:
Cons:
In general, I think conditional comments are better than CSS hacks.
It's entirely dependent on how much content you have in each file and how you want to group them. The separation of files is for your convenience as a maintainer, not a technical issue.
* html
(to hide from IE6) is the only CSS hack you're likely to want to use today. If you need more flexibility than that, then yes you'll want conditional comments, but no that doesn't mean you have to have separate stylesheets if you don't want to. And if you've only got a couple of hacks, you probably don't want to.
eg. in the markup you can add IE-specific classes
<!--[if lt IE 7]><body class="ie6"><![endif]-->
<!--[if (gte IE 7)&(lt IE 8)]><body class="ie7"><![endif]-->
<!--[if gte IE 8]><!--><body class="ok"><!--<![endif]-->
Now you can target IE without hacks:
body.ie6 .foo { ... }
body.ie7 .foo { ... }