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 CSS Basics (2014) Getting Started with CSS Importing Style Sheets with @import

@import

What is the difference between using the style tags with the @import in the head of html vs putting the the @import in the css file? Also can someone explain this @import further as I'm not understanding how or when I'd use it?

2 Answers

Hey Bridget

There is no difference, you can put your entire CSS markup in between style tags if you want but this is very bad practice as it get messy really quick.

The reason you may want to import a stylesheet into another stylesheet is if you wanted to break up your CSS into easier to manage chunks for instance one for colours, one for fonts etc, then you only need to link one stylesheet in the html file.

Hope that made sense :-)

Happy coding

Paul

Mark Casavantes
PLUS
Mark Casavantes
Courses Plus Student 13,401 Points

Hello Bridget,

When you have a small website everything can be on one page. When you have larger programs it is easier to organize your site using different files. It is common to have an HTML file, a CSS file, a JavaScript file etc... To be able to use these files they need to be imported into your other pages.

https://developer.mozilla.org/en-US/docs/Web/CSS/@import

I hope this is helpful.

Mark