Re:Ask HN: Anyone have a really smart way to organize css?
by steverenz on Sunday March 27, 2011 @11:45PM
(#2377045)
I agree completely, especially on a web app that is constantly growing. 2 on-the-job things that help me the most are:
1. Using the 960 grid system (or your preferred grid flavor) 2. Grouping by the following:
Body Typography Forms (Other global stuff like links and buttons) /* Layout Element 1 / ID1 {} ID2 {} class1 {} class2 {} / Layout Element 2 */ ID3 {} ID4 {} class3 {} class4 {}
I also write my styles on one line, but that's just personal preference. I find it easier to scan down for the selector, then across for the property I want. I definitely don't do it for aesthetics or file size ;)
This is especially true when you're working either in a team environment or on a large site. The very nature of CSS (and how things cascade down) can become a nightmare when organization isn't taken into account from the start.