Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

P-Worm

macrumors 68020
Original poster
Jul 16, 2002
2,045
1
Salt Lake City, UT
I'm just wondering what the best way to organize a site full of CSS so that when style changes are made there is no need to revisit a lot of pages while still maintaining readability.

Right now, I have a single CSS file called main_style that has all of the style information for the overall site. Is it possible to make new CSS files that point to main_style and then amends that file? For instance, if I have a subgroup of pages that are supposed to look like the main style, but I want to add some extra style choices that apply only to that subgroup, but not to the rest of the site, can I make a file that will look up all of the information in main_style and then add the new choices? Obviously, I can make a new file and copy all of the main_style stuff into the new file and amend from there, but that makes the new file bigger than I would like and also means that I need to change both sheets if I want to change the style of the overall site.

Is there a clean solution to this that I'm not aware of?

Thanks,

P-Worm
 
Since CSS cascades any new style definitions will override or be appended to previous ones. So you could just import the main_style file on every page and then for the sub-group just import the file with the other styles.

Example
Code:
<style type="text/css">
   @import "main_style_url.css"
   @import "subgroup_style_url.css"
</style>

The way you import the files (or link to them) is not important, just the order is. Just make sure the files containing styles to override the main_styles are imported after the main_style.
 
I just include multiple CSS files. I have my main one, then I add an additional one if it's in a specific part of the web site. Including multiple CSS files has the same effect as appending them together.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.