What are the best practices for making CSS layouts with fewer selectors and fewer DIVs?
Fewer selectors means less HTML and CSS, which is easier to manage.
How can we avoid using too many class/other selectors?
What are the best practices for making CSS layouts with fewer selectors and fewer DIVs?
Fewer selectors means less HTML and CSS, which is easier to manage.
How can we avoid using too many class/other selectors?
Among other topics there is how to:
Great resource and a must read for any developer as well as designer.
You can try LESS. It does in a way help you to minimize the amount of repetetive coding.
What are the best practices for making CSS layouts with fewer selectors and fewer DIVs?
There are three of these:
div
s unless you need them.Fewer selectors means less HTML and CSS, which is easier to manage.
I know, right? The easiest page I ever managed had no selectors and no tags at all, and was in fact a text file!
How can we avoid using too many class/other selectors?
Use tag selectors.
I know, I know... Some folks like to give everything classes, thinking to themselves, "I might some day want to make odd-numbered paragraphs bright red with a royal blue background, and it'd be a real shame if I had to go back and modify the markup first." But that's just silly - red on blue is horrible. Avoid adding classes until you need to; that is, avoid adding classes until you've used up all of the tags. HTML has lots of tags, so use 'em.
Check out Sass (Syntactically Awesome Stylesheets). It helps you write CSS that's leaner and more maintainable.
Sass makes CSS fun again. Sass is CSS, plus nested rules, variables, mixins, and more, all in a concise, readable syntax.