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

Andre Kucharzyk
Andre Kucharzyk
4,479 Points

I really dont get what is the difference between link and import. Could anybody try explaining it to me?

.

2 Answers

Flor Antara
Flor Antara
12,372 Points

Hi Andre,

Adding to Daniel's answer, take a look at the answer from this question where I explain the performance point. https://teamtreehouse.com/community/regarding-import-for-font-style

Long story short:

  • <link> is what you use to include stylesheets from an HTML file.
  • @import is what you use to do the same from a CSS file. (A CSS file inside another, yes!)
  • <link> is better for performance since it adds the resource to a parallel download queue without blocking the rendering of the page.

Thought to share an answer to a similar question posted on a different forum that i believe really answered the question as I understood it:

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.