Organize CSS - File points to other file?

Discussion in 'Web Design and Development' started by P-Worm, Oct 12, 2008.

  1. P-Worm macrumors 68020


    Jul 16, 2002
    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?


  2. Kaliemon macrumors member

    Apr 30, 2006
    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.

    <style type="text/css">
       @import "main_style_url.css"
       @import "subgroup_style_url.css"
    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.
  3. angelwatt Moderator emeritus


    Aug 16, 2005
    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.

Share This Page