I agree. 2nd example is better. I had always done it the first way for a long time. But as I've gained experience, I have come to like the second approach. If you have a lot of styles that overlap, that approach really saves not only space but makes changes a lot easier.
What I usually do is write my code in the way I want each class or ID styled. When I'm finished I'll go back through and combine the similarities between classes or ID's (show in example 2).
Which example better?
First Example:
Second example
2nd example...if only because it has a smaller file size.
I agree. 2nd example is better. I had always done it the first way for a long time. But as I've gained experience, I have come to like the second approach. If you have a lot of styles that overlap, that approach really saves not only space but makes changes a lot easier.
What I usually do is write my code in the way I want each class or ID styled. When I'm finished I'll go back through and combine the similarities between classes or ID's (show in example 2).
thanks for comment :)
@ChristopherBurton: why don't you do that the first time?
Ontopic: second approach
@Vermaas It's just the way I work. No particular reason.
One more example:
Which example better?
First-example:
Second-example:
Either works.
I tend to use the first option for single background images.
If I have multiple bg images then I find it somewhat easier to comma separate onto individual lines and each property.