by simonw · 15y ago · 0 comments
http://lanyrd.com/2008/barcamp-london-5/sg/
She splits everything in to general styles (basic HTML elements), helper styles (things like forms, notifications, icons), page structure (header, footer, layout columns etc), page components (reusable composable classes for components that occur on different pages in different combinations, such as a news teaser) and over-rides (special cases for individual pages, rarely used).
She hardly ever uses IDs, preferring classes for almost everything - because CSS written against classes can be used more than once on a page.
She uses CSSEdit's groups feature to make the CSS easier to navigate - it's all in one file. http://macrabbit.com/cssedit/
View the stylesheets on http://lanyrd.com/ and follow the link at the top to the unminified version to see annotated examples.
We use a far-future expires header (and serve from Amazon CloudFront), so browsers should only ever fetch the file once no matter how many pages on the site the user visits.
Don't worry, I'm sure all those developers are "doing it wrong" too.
I think it also has to do with frameworks. Sometimes frameworks spit out a lot of HTML you won't ever need. So the HTML is bloated in the first place. Then it's a hell of a job to style the mess.
When you are fortunate to control the HTML you should first start to optimize your HTML before you even start with CSS.
Goes hand-in-hand with javascript to ease selector targeting.
I never scope ID's either, that's the wrong way to do it. An ID is always unique so it is top-level.
I agree about IDs for JavaScript though.
Ids should be used only for scripts, and most of the time should be auto generated anyway.
Would you mind elaborating on the JavaScript point? Is it for convenience with document.getElementById or something?
Using jQuery, I tend to prefer class selectors the same as in my CSS.