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

What will be faster @import or link?

I would like to add normalize.css and some css fonts before my main css style, so what is the best solution for this? Linking files with link tag in html or using @import in css?

3 Answers

link is preferred in all cases over @import, because @import blocks parallel downloads, meaning that the browser will wait for the imported file to finish downloading before it starts downloading the rest of the content.

Sergey Podgornyy
Sergey Podgornyy
20,660 Points

In theory, the only difference between them is that @import is the CSS mechanism to include a style sheet and

<link>

the HTML mechanism. However, browsers handle them differently, giving

<link>

a clear advantage in terms of performance.

Steve Souders wrote an extensive blog post comparing the impact of both

<link>

and @import (and all sorts of combinations of them) called "don’t use @import". That title pretty much speaks for itself.

Yahoo! also mentions it as one of their performance best practices (co-authored by Steve Souders): [Choose

<link>
``` over `@import`](https://developer.yahoo.com/performance/rules.html#csslink=).

Also, using the 

<link>

 tag allows you to define ["preferred" and alternate stylesheets](http://alistapart.com/article/alternate). You can't do that with `@import`.

Thank you very much for your answers, Jackson and Sergey. Now it's clear for me! :)