Advanced Search

Results 1 to 3 of 3

Thread: 1 style sheet or many?

  1. #1
    Join Date
    Jan 2009
    Location
    NH
    Posts
    302
    Thanks
    38
    Thanked 8 Times in 8 Posts

    Question 1 style sheet or many?

    I was looking at a site someone wanted help with. The original designer had at least 5 style sheets, some very short with just 1 0r 2 things in it.

    Is it not better to use just 1 and link every page in the site to it??

    thanks

  2. #2
    Join Date
    Mar 2006
    Location
    Illinois, USA
    Posts
    12,154
    Thanks
    260
    Thanked 690 Times in 678 Posts

    Default

    It depends. CSS stylesheets aren't large enough files that it should ever really matter.

    There are three things to consider:
    1. It is best to not reload the same information repeatedly. (Therefore, using external stylesheets in general is a good idea).
    2. Loading more files (here, more CSS files) means more requests. But in the real world, the difference between 1-5 requests isn't a major consideration. So, yes, better to have one file, but not disastrous without it.
    3. Each file will load faster if it is smaller. As CSS is just text, that's not a serious problem-- even a long CSS file will load quickly (probably faster than he actual response time for the request from the server). But in theory for this reason it's better to only load what is needed. So if those extra files are for parts of the site that may not be needed, it may be slightly better to not make everyone load all of the styles if they may not visit those other pages.


    Generally speaking I'd suggest one stylesheet per section of the site. And for convenience you can split it more if it's getting too long to manage. Having just 1-2 lines in a stylesheet seems odd to me. There's no harm in combining them.

    The only other reason I can think of to split them is if they conflict-- one says that text should be blue and one says that text should be red. That's a good reason to have two stylesheets. There are workarounds to it, but not just by combining the stylesheets. (You'd need to apply classes to the different pages and set that up in the stylesheets.)
    Daniel - Freelance Web Design | <?php?> | <html>| espa˝ol | Deutsch | italiano | portuguŕs | catalÓ | un peu de franšais | some knowledge of several other languages: I can sometimes help translate here on DD | Linguistics Forum

  3. #3
    Join Date
    Jan 2013
    Location
    Central Connecticut
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    mlegg, one thing you should look at carefully is the order in which these five stylesheets are called. CSS means Cascading Style Sheet so, if you are combining several into one, you should be aware of the cascade and put the stuff in the last style sheets last.

    I tend to have up to about three style sheets in my websites. One for general page layouts, one for navigation and a third as an auxiliary for anything special, like an online store section or some other widget like a slide show where I need to format text or layout within a particular section differently.

    Usually a web browser can keep a certain amount of stuff in RAM, so things that are used by all pages, like JavaScript and style sheets that are common to all pages should be externalized and loaded in all pages first. That speeds up the loading of all pages in the website after the initial page loads.

Similar Threads

  1. Using more then one CSS style sheet
    By cimm.mann in forum CSS
    Replies: 1
    Last Post: 07-28-2009, 01:41 AM
  2. Style Sheet Switcher (v1.1) - random style on every new site visit
    By matteus in forum Dynamic Drive scripts help
    Replies: 6
    Last Post: 07-07-2008, 04:09 PM
  3. One main style sheet or many?
    By Sliight in forum CSS
    Replies: 6
    Last Post: 07-16-2007, 05:10 PM
  4. CSS Style Sheet
    By khuba in forum CSS
    Replies: 0
    Last Post: 06-03-2006, 12:22 PM
  5. Style Sheet Switcher (v1.0) - IE does not remember style
    By miodrag in forum Dynamic Drive scripts help
    Replies: 4
    Last Post: 06-02-2006, 01:13 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •