12-12-2010, 11:12 PM
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
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?
12-12-2010, 11:43 PM
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,
12-13-2010, 04:43 PM
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.
12-13-2010, 05:07 PM
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.
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
12-13-2010, 08:49 PM
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.
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.