The @import at-rule includes another stylesheet into the current CSS file. Use it to split styles into smaller files, then pull them together from one place.
Put every @import at the top — after optional @charset, and before other style rules. You can add a media condition so the import applies only on matching devices.
Warning — prefer <link> for performance.
HTML <link rel="stylesheet"> can fetch sheets in parallel. @import often loads more sequentially and may delay first paint. Use @import when you need CSS-side composition or media-gated imports.
Baseline Widely available.
Core @import is a long-standing CSS feature. Newer extras like layer() and supports() need newer browsers — keep beginner examples to URL + optional media.
Syntax
CSS Syntax
syntax.css
@import <url> | <string> [ <media-query-list> ]?;
/* common forms */
@import url("theme.css");
@import "theme.css";
@import url("print.css") print;
A URL (or quoted string) is required. Media queries are optional. End with a semicolon.
Stack imports. Each @import stays above normal rules.
Rules last. Selectors and declarations follow.
Avoid late imports. An @import after a rule is ignored.
Edge Cases & Pitfalls
Most import bugs are placement, path, or performance issues.
place
Must stay above style rules
If any normal rule appears first, later @import lines are ignored.
perf
Can delay rendering
Nested or chained imports often load less efficiently than multiple HTML <link> tags.
path
Relative URLs resolve from the CSS file
Paths are relative to the importing stylesheet, not the HTML page.
cycle
Avoid circular imports
A imports B and B imports A creates confusion and wasted work. Keep a clear one-way graph.
newer
layer() and supports()
Modern forms can assign cascade layers or feature checks. Learn core URL + media first, then add these when needed.
Compatibility
Browser Support
@import is a browser CSS feature for including stylesheets. Node.js, Deno, and Bun do not apply it as a layout API.
✓ Baseline · Long supported
@import
Chrome 1+, Firefox 1+, Safari 1+, Edge 12+, Opera 3.5+, Internet Explorer 5.5+, Samsung Internet 1+.
99%All major browsers
Google Chrome1+
Full support
Mozilla Firefox1+
Full support
Apple Safari1+
Full support
Microsoft Edge12+
Full support
Opera3.5+
Full support
Samsung Internet1+
Full support
Internet Explorer5.5+
Full support
@importUniversally supported
Bottom line: Safe everywhere for basic URL imports and media lists. Prefer <link> for critical production CSS when possible. Not a server runtime API.
Remember
Key Takeaways
Role: include another stylesheet into the current CSS file.
Order: after @charset, before other style rules.
Optional media: gate imports with a media type or query.
Tip: use HTML <link> for critical CSS when performance matters.
One line:@import url("file.css"); at the top pulls that sheet into your cascade.
Frequently Asked Questions
It pulls another stylesheet into the current CSS file. Imported rules apply as if they were written in that file, in import order.
After an optional @charset, and before other style rules. If a normal rule appears first, later @import lines are ignored.
For most pages, <link rel="stylesheet"> in HTML is better. Linked sheets can download in parallel. @import often loads more sequentially and can delay rendering.
Yes. Append a media type or query after the URL, such as @import url("print.css") print;. Styles apply only when the condition matches.
Yes, browsers accept @import inside <style>, but the same placement rules apply. Prefer linked CSS files for production sites.
It is Baseline and long supported in Chrome, Firefox, Safari, Edge, Opera, and Internet Explorer. It is a browser CSS feature, not a Node.js API.