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.media

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
CSS Object Model (CSSOM) (CSSOM)
# the-cssimportrule-interface

Browser compatibility

BCD tables only load in the browser