3 ms·
I love the crap out of CSS, but a lot of these points are just opinion, and I would not recommend this guide to anyone who wants to write more maintainable CSS.
by meesterdude 11y ago
I love the crap out of CSS, but a lot of these points are just opinion, and I would not recommend this guide to anyone who wants to write more maintainable CSS.
Things like calling it "the best" and having "right" and "wrong" in the examples are really just arrogant and not grounded in anything solid. In CSS, there is no right/wrong, thats the point. CSS is not black & white, it's flexible.
It's not all bad, of course; things like the spacing between the colon of a definition I thought were self evident.
> CSS rules should be comma separated and leave on a new line
Wat. Ok, sure, you CAN do that. And if you have complex selectors, you should. but for "a,img" theres no clarity gained by new lining them.
> Rule declarations should have one property per line
Generally yes. But there are times when a one-liner is clearer and easier to comprehend.
> Do not nest elements.
Do not listen to this! The author is correct that this can lead to over specificity, and that is certainly something you should be aware of. But it also lets you do things like not have to put classes on everything, and focus more on what makes semantic sense in the HTML. Personally, i go two to three levels; still allows for flexibility (like moving an article to be within a div) while letting you easily scope out everything having to do with a particular element and it's children. and code folding!
> You should use single quotes as it is visually clearer that the string is not a selector or a style property.
I agree with this; you should, it's clearer, and allows for syntax highlighting to make it easier to spot.
Anyway, the best CSS is CSS you can understand, refactor, and expand upon. What CSS and CSS processors allow for is a lot of flexibility that can be abused if you're not careful, or very powerful if you know what you're doing. We are all students of CSS, still trying to figure out what is a good idea and what is not. Take everything with a grain of salt.
Take what is useful from this for you, discard the rest. But don't count it as gospel. For those of us who've been around CSS, this is probably obvious; but for people just picking it up, I would discourage latching onto this as definitive.
If I was the author: i would actually give this a name. like "super totally awesome CSS" or something. then you can make sweeping right/wrong judgements and any other style declarations you want, because they are contextual to a specific philosophy and school of opinion. Like google's material design does.
- grvcoelho 11y agoHello there! Awesome feedback :) Although perhaps I exaggerated the name of this thread (sorry, I'm new here), the repository DOES say it's an opinionated guide! Also, these are not rules, these are my guidelines and recommendations! When I say right or wrong, I mean based on the styleguide itself! Tks for the feedback!