Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

CSS CSS Basics (2014) Getting Started with CSS Importing Style Sheets with @import

Tony Brown
PLUS
Tony Brown
Courses Plus Student 1,678 Points

Instead of using @import in the external css, couldn't we reference the normalizing stylesheet in the head of the html?

Instead of using @import in the external css, couldn't we reference the normalizing stylesheet in the head of the html using a style element, like below?

Instead of have the following at the top of the external css file to normalize the css: @import "import-styles.css";

Couldn't we also do the following inside the head of the html?

<link rel="stylesheet" href="css/import-styles.css">
<link rel="stylesheet" href="css/style.css">

2 Answers

Ryan Field
PLUS
Ryan Field
Courses Plus Student 21,241 Points

You certainly could, and in fact, if you have a lot of CSS files, that way might be better since the @import directive causes the browser to make another call instead of loading it asynchronously. With CSS preprocessors like Sass, this is less of an issue since all your CSS goes in one file, but in general, I believe it is best practice to refrain from making too many @import calls.

Guil Hernandez
STAFF
Guil Hernandez
Treehouse Teacher

Hi Anthony Brown,

Sure you can. They both require an extra request to the server – they're just being made from different locations.

In most cases, you're better off linking a style sheet since @import blocks parallel downloading. The browser has to wait to @import a file before downloading the rest of the file...

Tony Brown
Tony Brown
Courses Plus Student 1,678 Points

Thanks, Guil! But I went and tried using the link element and the styles didn't apply to page. Any thoughts?