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

Why @import instead of copy and paste?

I'm struggling with understanding the use of @import. I understand that it's basically CSS version of <link> but I don't understand why you wouldn't just copy and paste all the code from the file you're importing, to the CSS file you're doing. Wouldn't you want all of the CSS to be right there to manipulate anyways instead of jumping to different CSS files?

1 Answer

Martin Sole
Martin Sole
82,023 Points

Hi

It is more so you can keep your CSS concise and readable, it makes easier to find things if components, for example buttons, are all grouped together in an individual file. This particularly helpful when working on large websites and in instances where someone else may have done a large portion of the work and you have now taken over.