Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

CSS

Chelsea Obrien
Chelsea Obrien
1,954 Points

Why do we use another CSS file instead of just adding the responsive rules at the bottom of main.css?

Curious to understand why we create a new file instead of simply adding to main.css, since the new responsive declarations would be at the end of the cascade. Is it simply because it's "cleaner" to do this? Or easier for editing in the future...?

2 Answers

Basic CSS tutorials here will not go too deep into how a project should be organized, since that is a topic that would likely overwhelm most people new to CSS and web dev/design, but ideally, when you put a website out onto the web, you will have nearly all of the styles you have written in a single style sheet. This is better then having many, since you are requesting less files from the server to download on the client's end. However, when developing a website you want to organize your CSS into logical groups and keep them in separate files so you and your team(if you are on one) are more organized + efficient.

Tools that let you have the advantage of both include things like:

  • SASS or LESS, which allows you to create a bunch of SASS or LESS files that merge into one CSS file
  • Grunt or Gulp, can be run to merge a bunch of files into one output file, and many more useful things

Now, like I mentioned earlier, these are intermediate to advanced topics for CSS, and while it is okay to know about them early in your CSS learning career, I would recommend becoming pretty comfy with CSS first, so you don't overload your brain with too much stuff to remember :P

I hope this helped!

Chelsea Obrien
Chelsea Obrien
1,954 Points

Thank you, that's a superb answer. Makes total sense. I appreciate you taking time to explain!