Next Question
RSS
It really depends on the situation, and your own or teams preferences and what you want to achieve.
For readability and understandability it is good to clearly organize and label (comment, indent and space out) your styles as well as separate them into common groups. If you have a single file, it can become a bit long with lots of content, and this affects readability, and the ability to find a specific portion of the file.
So if the CSS file becomes too large, you might want to consider separating different sections into different files. This is largely based on your CSS editor also. Editors that do not manage multiple files well can be a hindrance. Screen size also plays a factor, as large screens are well suited for single files.
Too many files can make things more complex then necessary. Here, it makes more sense to make each file more readable, then to separate them.
It also helps to have good version control. For this you can use SVN, or GIT.
SVN - http://subversion.tigris.org/
GIT - http://git-scm.com/
This helps the management of the CSS files as well as other files.
For organizing CSS see:
http://www.smashingmagazine.com/2007/05/10/70-expert-ideas-for-better-css-coding/
To consider how single or multiple CSS files affect load time. The browser usually has to wait for all the files to load before rendering styles. Multiple files mean that there are more HTTP requests made, and this usually means it will take longer.
There are many factors affecting how the CSS files will load. Browser usually only have a 2 connection limit per domain (2 TCP sockets) concurrently. So multiple files may or may not be downloaded concurrently due to this limit. There are other factors such as HTTP version used, support HTTP features on both server and browser (eg: HTTP pipelining), intermediate or browser cache, etc.
For loading multiple CSS files see:
http://www.cherny.com/webdev/53/on-http-page-load-times-multiple-file-requests-and-deferred-javascript
Source(s):
Web Development experience - http://www.fijiwebdesign.com/
http://www.cherny.com/webdev/53/on-http-page-load-times-multiple-file-reque...
http://www.smashingmagazine.com/2007/05/10/70-expert-ideas-for-better-css-c...
Permalink | Report
lookacleve...
robbrown
Having multiple files can get confusing, and requires more HTTP requests (even though it's only for the initial pageview).
Permalink | Report
Answered Question
February 05, 2009 11:51 AM
Which is better, single or multiple css files? What are the benefits?
Is it better to use multiple css files for building a site or using a single file that contains all styles?
Interesting Question?
Yes (1)
No (0)
- In Web Design |
- |
- Report |
-
Share
RSS
Best Answer Chosen by Asker
| February 05, 2009 03:16 PM |
For readability and understandability it is good to clearly organize and label (comment, indent and space out) your styles as well as separate them into common groups. If you have a single file, it can become a bit long with lots of content, and this affects readability, and the ability to find a specific portion of the file.
So if the CSS file becomes too large, you might want to consider separating different sections into different files. This is largely based on your CSS editor also. Editors that do not manage multiple files well can be a hindrance. Screen size also plays a factor, as large screens are well suited for single files.
Too many files can make things more complex then necessary. Here, it makes more sense to make each file more readable, then to separate them.
It also helps to have good version control. For this you can use SVN, or GIT.
SVN - http://subversion.tigris.org/
GIT - http://git-scm.com/
This helps the management of the CSS files as well as other files.
For organizing CSS see:
http://www.smashingmagazine.com/2007/05/10/70-expert-ideas-for-better-css-coding/
To consider how single or multiple CSS files affect load time. The browser usually has to wait for all the files to load before rendering styles. Multiple files mean that there are more HTTP requests made, and this usually means it will take longer.
There are many factors affecting how the CSS files will load. Browser usually only have a 2 connection limit per domain (2 TCP sockets) concurrently. So multiple files may or may not be downloaded concurrently due to this limit. There are other factors such as HTTP version used, support HTTP features on both server and browser (eg: HTTP pipelining), intermediate or browser cache, etc.
For loading multiple CSS files see:
http://www.cherny.com/webdev/53/on-http-page-load-times-multiple-file-requests-and-deferred-javascript
Source(s):
Web Development experience - http://www.fijiwebdesign.com/
http://www.cherny.com/webdev/53/on-http-page-load-times-multiple-file-reque...
http://www.smashingmagazine.com/2007/05/10/70-expert-ideas-for-better-css-c...
Permalink | Report
lookacleve...
February 05, 2009 03:52 PM
Agreed. Good Answer.
Tip lookacleverusername for this comment
Report
robbrown
February 05, 2009 04:10 PM
Good Answer!
Tip robbrown for this comment
Report
Other Answers (2)
February 05, 2009 01:03 PM
I prefer to use one CSS file. I delineate each section (the reset section, layout, typography, etc...) using commented out lines of dashes/underscores, and navigate around it using whatever code editor I'm using's "find" functionality. Having multiple files can get confusing, and requires more HTTP requests (even though it's only for the initial pageview).
Permalink | Report
Answer this Question
Related Questions
Ask a Question
Buy Mahalo Dollars with Credit Card or PayPal
Top Members
Most Popular Tags
Categories
- Anonymous
- Arts & Design
- Beauty & Style
- Books & Authors
- Business
- Cars & Transportation
- Consumer Electronics
- Coupons Deals
- Education
- Entertainment
- Environment
- Fitness
- Food & Drink
- From Email
- From Iphone
- From Twitter
- Health
- History
- Hobbies
- Home & Garden
- How Tos
- Humor
- Jobs
- Legal
- Local
- Love & Relationships
- Mahalo Answers Community
- Money
- Music
- News
- NSFW
- Parenting
- Pets
- Science & Mathematics
- Services
- Shopping
- Social Science
- Society & Culture
- Sports
- Technology & Internet
- Travel
- Video Games
Welcome New Members
- marcbass, November 30, 2009 07:55 PM
- jonathansheely, November 30, 2009 07:48 PM
- jonathansheely2, November 30, 2009 07:48 PM
- fuyujishido, November 30, 2009 07:47 PM
- killerzpunk, November 30, 2009 07:43 PM
Mahalo Dollars are the currency of Mahalo Answers.
Each Mahalo Dollar costs $1.
Once you earn more than 40 Mahalo Dollars, you can request to be paid via PayPal. Each Mahalo Dollar is currently worth $0.75 when paid out via PayPal. Learn More