CSSImportRule

The CSSImportRule interface represents an @import at-rule.

Properties

Inherits properties from its ancestor CSSRule.

CSSImportRule.hrefRead only
Returns the url specified by the @import rule.
CSSImportRule.mediaRead only
Returns the value of the media attribute of the associated stylesheet.
CSSImportRule.stylesheetRead only
Returns the associated stylesheet.

Methods

Inherits methods from its ancestor CSSRule.

Examples

The following stylesheet includes a single @import rule. Therefore the first item in the list of CSS rules will be a CSSImportRule.

@import url("style.css") screen;
let myRules = document.styleSheets[0].cssRules;
console.log(myRules[0]); //a CSSImportRule

Specifications

Specification Status Comment
CSS Object Model (CSSOM)
The definition of 'CSSImportRule' in that specification.
Working Draft No changes from Document Object Model (DOM) Level 2 Style Specification
Document Object Model (DOM) Level 2 Style Specification
The definition of 'CSSImportRule' in that specification.
Obsolete Initial definition

Browser compatibility

BCD tables only load in the browser