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

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,359 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.