Let’s face it, navigating and maintaining large CSS files is no fun. As long as the site is small or if you happen to be in the early stages of development, the CSS file looks manageable, but once you hit the 2k+ line mark, finding what you are looking for can take a while. Not to mention how your team is going to pollute your style.css if the file structure is overly complicated.
With some proper CSS file organization, you can wave these problems goodbye. What I am suggesting here is an organization style that has worked for me and my team so far. Let’s dig into it.
Structure
1. Reset
I could as well link one of the many reset.css style sheets, but to save on server requests, I’ve decided to put the reset styles on the top of my main CSS file.
2. Base
The html, body and defaults for other basic html elements go here. This section is usually pretty minimal, because I like to style elements as they come along in the source. That way I have more control over the styles and less overriding to do later on.
3. Structure
You might opt to let this section go, depending on whether you like to separate the container divs from other styles or not.
4. Header
The definitions for styling the header of your site go here.
5. Content
The definitions for styling the content section of your site go here.
6. Footer
The definitions for styling the footer of your site go here and again you might skip this section if your site has no footer.
7. Navigation
The various menus, breadcrumbs indicator, etc.
8. Modules
I use this section to define the separate modules or blocks used on my site. News, polls, events lists, flickr feeds, quick links, and similar sections are usually defined here.
9. Forms
I like to put all the forms in one place, this proved to be a wise decision over time.
10. Custom Classes
I put here various reusable classes that are frequently shared throughout the site. You might not need this section if your site is a simple one, but when it grows too complex, you might find this section handy.
11. Everything Else
All that you can’t fit anywhere above. Usually this section only ends up only having a few classes.
12. Print Styles
If you don’t store your print styles in a separate file, this is the place to define them with a @media print block. You should put this section as the last one, as you potentially want to override any previous CSS declaration.
Sample
Here is some code from a sample style file. I’ve omitted most of the code for simplicity sake, but I’ve left section and sub-section comments in.
So, here it is – a nice organized layout for your CSS declarations. I hope you find it useful as much as I did and I’d love to hear from you if you have any comments or suggestions to improve this.








