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 trialDean Onizuka
4,753 Pointspurpose of @import and css style sheet linking of media queries
is there any instance where we would use the @import function for media queries that were shown in this video? or linking them in the html file via stylesheet like tags?
seems like the media queries work just fine without going to those lengths or am i missing something here?
2 Answers
Jacob Herper
94,150 PointsYou can import CSS files into other CSS files to contain a clear structure. However most of the time you would rather include multiple CSS files through your HTML file, as @import might prevent stylesheets from being downloaded concurrently and slows down your page loading time. So the html link element is a better choice.
James Gill
Courses Plus Student 34,936 PointsAlso, older browsers don't support @import. So, in a roundabout way, you can use @import to "hide" styles from these older browsers (@import doesn't work for them, so they ignore the imported file).
But as Jacob said, I think it's best to go ahead and <link> the style sheet within the HTML.