The above seem to be contradictory goals.
On the one hand, making CSS maintainable seems to me to suggest keeping CSS structured and orderly, and keeping all the styles of an element together in one place.
So for example, the style of a top logo would look like this:
#logo {
width:50px;
height:30px;
background-image:url(/images/logo.gif);
background-repeat:no-repeat;
background-position:left top;
border:solid 1px blue;
}
As you can see, in the above case, one only has to look in one spot if one wants to update the logo style.
The problems begin when we want to make the site "theme-able", and separate the brand-specific elements from the essential elements.
In this case, we might have the '#logo' style spread across two stylesheets:
site.css:
#logo {
width:50px;
height:30px;
background-repeat:no-repeat;
background-position:left top;
}
brand.css:
#logo {
background-image:url(/images/logo.gif);
border:solid 1px blue;
}
Now our CSS is more flexible but less maintainable, since every time we edit '#logo', we'll have to look at two files and decide which to alter.
It gets exponentially worse if we decide to separate typography into another file, or IE 6 fixes into yet another file.
How do we deal with this complexity?
Do we sacrifice maintainability for flexibility?
Is there some middle-ground between the two?
Are CSS Variables the only answer?
I'm seeing a lot of intelligent answers but still not the advice I'm looking for.
Here's what I'm really getting at:
Suppose I decide to separate Theme styles from Main styles. How do I separate by components then?
Do I still separate Header CSS from, say, a Media Player component? Or do I just give up and mash them all together?
Or do I use 'sections' within Main.css and Theme.css?
Or do I use separate files for each combination of component and aspect? For example:
- Header.base.css
- Header.theme.css
- Mediaplayer.base.css
- Mediaplayer.theme.css
- etc...