At 12:21 PM 2/16/2005, Jason Kohls wrote:
>I've seen multiple stylesheets created for different media types,
>browsers, but I haven't seen anyone attempt to create separate
>stylesheets along the lines of normal Web site partitioning, namely
>"Navigation", "Layout", "Typography" or content-specific partitions,
>"Products", "Legal", and so on. Looking at the programming world, this
>sort of encapsulation is commonplace.
I modularize stylesheets routinely. Usually I have one called "global.css"
that applies general rules to the entire site, other files that are
specific to sections of the site, and perhaps others that are for specific
pages. Sometimes I'll put the styles that apply to a global navigation
menu in a file by itself, just to make it easier for me to manage.
Modularizing stylesheets is more for my benefit as a programmer than for
system performance. Since stylesheets are cached, their size is
significant only when you download them the first time. That's an argument
against splitting your styles into too many separate files, by the way. I
think it's a safe bet that it's faster to download one 20kb file than to
download two separate 10kb files. One huge honker stylesheet might take a
couple of seconds to download the first time, but then it's there for all
In some complex sites, I've found it's convenient to split styles between
structural layout rules that apply to groups of pages and more "cosmetic"
rules such as colors & background images that vary from one web page to
another. One thing this means is that, given a particular structural
layout, it's easier to change skins when the colors & images aren't buried
in the rest. The downside is having to manage selectors in more than one
file. (This is less of a problem for me since I editing with Visual Studio
which can open & search through multiple text files, so I can look for
At the same time, I frequently give each HTML page's body element an id or
class. This allows me to apply different rules to different pages easily
from the same stylesheet.
Another common approach is to isolate special rules for wonky browsers in
separate files: ie.css, macie5.css, etc. This helps separate ugly hacks
from normal rules, and will make the specialized hacks easier to dispense
with in that golden future when those icky old browsers finally ooze back
into the swamp whence they came.
List wiki/FAQ -- http://css-discuss.incutio.com/
Supported by evolt.org -- http://www.evolt.org/help_support_evolt/