CSS import rule
Example
Import the "navigation.css" stylesheet into the current stylesheet:
@import
"
navigation
.css
";
/*
Using a string
*/
or
@import
url
("
navigation
.css
");
/*
Using a URL
*/
Browser support
The numbers in the table indicate the first browser version that supports this property.
| property | |||||
|---|---|---|---|---|---|
| @import | 1.0 | 5.5 | 1.0 | 1.0 | 3.5 |
Property definition and usage
CSS @import is used to import style rules from other stylesheets.
The @import rule must be at the top of a CSS document, but can come after @charset rules.
The @import rule is not a nested statement; @import cannot be used inside conditional group rules.
The @import rule also supports media queries, so you can import different stylesheets based on different screen sizes.
CSS Syntax
@import url|string list-of-mediaqueries;
Attribute values
| Value | Description |
|---|---|
| url|string | Specifies the address of the resource to import. This URL can be an absolute or relative path. Note that this URL does not need to point to a file; it can specify just a package name, and the appropriate file will be chosen automatically (e.g. chrome://communicator/skin/). |
| list-of-mediaqueries | A comma-separated list of media query conditions that sets the conditions under which the CSS rules imported by the URL apply. If the browser does not support any of the media query conditions in the list, the CSS file specified by the URL will not be imported. |
Example
More stylesheet import examples:
@import
url
("
fineprint
.css
")
;
@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
);