CSSImportRule

The CSSImportRule interface represents an @import at-rule.

CSSRule CSSImportRule

Properties

Inherits properties from its ancestor CSSRule.

CSSImportRule.href Read only

Returns the URL specified by the @import rule.

CSSImportRule.media

Returns the value of the media attribute of the associated stylesheet.

CSSImportRule.styleSheet Read 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
Unknown specification
# the-cssimportrule-interface

Browser compatibility

BCD tables only load in the browser