@import

The @import CSS at-rule is used to import style rules from other style sheets. These rules must precede all other types of rules, except @charset rules; as it is not a nested statement, @import cannot be used inside conditional group at-rules. So that user agents can avoid retrieving resources for unsupported media types, authors may specify media-dependent @import rules. These conditional imports specify comma-separated media queries after the URI. In the absence of any media query, the import is unconditional. Specifying all for the medium has the same effect.

Syntax

@import url; @import url list-of-media-queries;

Formal syntax

@import [ | ] [ ]?;

where
= #

where
= | [ not | only ]? [ and ]?

where
= | | |
=
= | |

where
= not
= [ and ]+
= [ or ]+
= ( ) | |

where
= ( [ | | ] )
= [ ) ] | ( )

where
= :
=
= [ '<' | '>' ]? '='? | [ '<' | '>' ]? '='? | '<' '='? '<' '='? | '>' '='? '>' '='?

where
=
= | | |

Examples

@import url("fineprint.css") print; @import url("bluish.css") projection, tv; @import 'custom.css'; @import url("chrome://communicator/skin/"); @import "common.css" screen, projection; @import url('landscape.css') screen and (orientation:landscape);

Specifications

Specification Status Comment
CSS Cascading and Inheritance Level 3
The definition of '@import' in that specification.
Candidate Recommendation
Media Queries
The definition of '@import' in that specification.
Recommendation Extended the syntax to support any media query and not only simple media types.
CSS Level 2 (Revision 1)
The definition of '@import' in that specification.
Recommendation Added support for to denote the url of a stylesheet,
and requirement to insert the @import rule at the beginning of the CSS document.
CSS Level 1
The definition of '@import' in that specification.
Recommendation Initial definition

Browser compatibility

Feature Chrome Edge Firefox (Gecko) Internet Explorer Opera Safari
Basic support (Yes) (Yes) (Yes) 5.5 (Yes) (Yes)
Feature Android Edge Firefox Mobile (Gecko) IE Mobile Opera Mobile Safari Mobile
Basic support (Yes) (Yes) (Yes) 5.5 (Yes) (Yes)