namespace

@import

Pulls another stylesheet into the current one at parse time, optionally scoped to a cascade layer, supports condition, or media query. It must appear at the top of a stylesheet, before all other rules except @charset and @layer statements.

@import url(<file>) [layer(<name>)] [supports(<condition>)] [<media-query>];

Common conditions / descriptors

Descriptor Purpose
url(<path>) The stylesheet to fetch and inline
layer(<name>) Import the file's rules directly into a named cascade layer
supports(<cond>) Only import when the feature query passes
<media-query> Trailing media query that scopes the imported rules
layer Import into an anonymous layer

Examples

@charset 'utf-8';
@import url('reset.css');
@import url('typography.css');

Imports must precede other rules (charset is allowed before)

@import url('print.css') print;

Import only for the print medium

@import url('framework.css') layer(vendor);

Drop a third-party stylesheet into a 'vendor' layer

@import url('grid.css') supports(display: grid) screen and (min-width: 768px);

Combine supports() and media query on a single import

Gotcha

Each @import is a render-blocking request that cannot start until the parent stylesheet is parsed — prefer bundling or in production. Any @import placed after a normal rule is silently ignored.

Related at-rules

← All CSS at-rules · CSS properties · CSS selectors