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

Kaycee Harris
Kaycee Harris
935 Points

@import

When do we use the @import? Also, would we create our own import-styles.css to link to our other style.css? Is the import-styles.css a default of styles or are they styles you create just breaking them up into sections? Please help

nakalkucing
nakalkucing
12,964 Points

Hi Kaycee Harris! I'm not entirely sure I understand your question, but if you're first question is where to place the @import statement:

The @import statement must precede all other CSS rules in a style sheet in order for it to work properly.

Hope this helps, and Happy Coding! :)

1 Answer

It is not a default style, as the word says; it let us import a style sheet.

The @import statement lets us import CSS from other style sheets. It shares some of the same advantages as linking a stylesheet, like browser caching and maintenance efficiency.

Importing another style sheet is not obligatory. However, linking your stylesheet is needed to add your presentation layer.