Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 7 of 7
  1. #1
    Regular Coder
    Join Date
    Aug 2010
    Posts
    133
    Thanks
    2
    Thanked 0 Times in 0 Posts

    Should I have 1 huge css file for all my pages? Or a few?

    I'm adding some new pages to my site, and some of them have different layouts than the rest of the pages.

    So I was wondering what I should do:
    have 1 .css file with the styling for ALL the pages on my site
    or
    have a few different .css files for the different types of pages that I have.

    Basically, its the difference between having 1 css file with extra stylings, or 3 css files without the extra css that other pages use.

    Does it make a difference for load times? or for server load? or for SEO?

  • #2
    New Coder
    Join Date
    Jul 2009
    Location
    Most of the time - internet
    Posts
    85
    Thanks
    0
    Thanked 1 Time in 1 Post
    Hi njfail,

    I use one large one for the layout and design of my website and for some pages I have additional style sheets.
    It wont increase load time by much (practically nothing) though remember you have 2 files instead of one on your server. Also remember that the two files are equivalent in size compared to one large one.
    ie) entireWebsite.css = 3000bytes (3kb) - This file contains all the styling for the entire site.
    main.css = 2500bytes (2.5kb) - This file contains the main design without the additional styling for other content on pages.
    profile.css = 500byes (0.5kb) - For example; if you were making a forum and this would be the styling for users profiles.

    Now if we add main.css and profile.css together we still get 3kb which is the same as putting main.css and profile.css together into one file (entireWebite.css)

    Keep in mind that if you are using a style sheet that contains the styling for ALL pages but the current page the user is on doesn't need that styling, it is just pointless for them to download it.

    I hope this helps,
    Dacoder96.

  • #3
    The Apostate Apostropartheid's Avatar
    Join Date
    Oct 2007
    Posts
    3,215
    Thanks
    16
    Thanked 265 Times in 263 Posts
    I would suggest on any moderate site to use one single stylesheet. The reason for this is that in the modern world, by far the thing which slows down a page the most is HTTP requests; you should try to keep these to a minimum.

  • #4
    New Coder
    Join Date
    Dec 2010
    Posts
    12
    Thanks
    0
    Thanked 0 Times in 0 Posts
    I think one file is better for multiple pages. But if the pages have absolutely different design then probably it's better to use several stylesheets.

  • #5
    Regular Coder
    Join Date
    Oct 2010
    Location
    San Antonio Tx
    Posts
    251
    Thanks
    12
    Thanked 11 Times in 11 Posts
    I say that depends on you cause your the one thats gonna be in there adding editing and working..if you use 1 style sheet I would comment the hell out of it so I dont forget whats what..or if making two is easier for you make two..I dont think it slows loading time by much at all

  • #6
    Regular Coder cineweekly.com's Avatar
    Join Date
    Aug 2010
    Posts
    485
    Thanks
    14
    Thanked 3 Times in 3 Posts
    I use one stylesheet since it's not that intensive on load times and would be better than multiple http requests which would be counterproductive. CSS stylesheets can start to add up but that's what they're made for, just make sure you keep it organized with comments.

  • #7
    Master Coder
    Join Date
    Apr 2003
    Location
    in my house
    Posts
    5,211
    Thanks
    39
    Thanked 201 Times in 197 Posts
    If you use external stylesheets, they are cached so they need not be downloaded for each page.

    but as others have said, managing the sheets is necessary too so, in my view, it's better to have a 'default' stylesheet for the whole site and in that, put the css for the individual pages at the bottom, so you can get the best of both worlds - efficiency and easier management.
    "The day you stop learning is the day you become obsolete"! - my late Dad.

    Why do some people say "I don't know for sure"? If they don't know for sure then, they don't know!
    Useful MySQL resource
    Useful MySQL link


  •  

    Posting Permissions

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