More CSS Topics: Importing a CSS file using @import

Join the AI Workshop to learn more about AI and how it can be applied to web development. Next cohort February 1st, 2026

The AI-first Web Development BOOTCAMP cohort starts February 24th, 2026. 10 weeks of intensive training and hands-on projects.


From any CSS file you can import another CSS file using the @import directive.

Here is how you use it:

@import url(myfile.css)

url() can manage absolute or relative URLs.

One important thing you need to know is that @import directives must be put before any other CSS in the file, or they will be ignored.

You can use media descriptors to only load a CSS file on the specific media:

@import url(myfile.css) all;
@import url(myfile-screen.css) screen;
@import url(myfile-print.css) print;

Lessons in this unit:

0: Introduction
1: CSS Variables (Custom Properties)
2: ▶︎ Importing a CSS file using @import
3: CSS Inheritance
4: CSS Comments
5: CSS Normalizing
6: The CSS z-index property
7: The CSS float property and clearing
8: CSS Feature Queries
9: How to print your HTML with style
10: CSS Vendor Prefixes
11: How to style lists using CSS
12: Styling HTML Tables with CSS
13: CSS Error Handling
14: Introduction to PostCSS