web api interface
CSSImportRule
The CSSImportRule interface represents an @import at-rule.
Instance properties
Inherits properties from its ancestor CSSRule.
hrefRead only- : Returns the URL specified by the
@importrule.
- : Returns the URL specified by the
layerNameRead only- : Returns the name of the cascade layer declared in the
@importrule, the empty string if the layer is anonymous, the ornullif the rule doesn’t declare any.
- : Returns the name of the cascade layer declared in the
media- : Returns the value of the
mediaattribute of the associated stylesheet.
- : Returns the value of the
styleSheetRead only- : Returns the associated stylesheet.
supportsTextRead only- : Returns the supports condition specified by the
@importrule.
- : Returns the supports condition specified by the
Instance methods
Inherits methods from its ancestor CSSRule.
Examples
The document includes a single stylesheet which contains a single @import rule. Therefore the first item in the list of CSS rules will be a CSSImportRule.
@import "style.css" screen;
const myRules = document.styleSheets[0].cssRules;
console.log(myRules[0]); // A CSSImportRule instance object
Specifications
SpecificationsStandards references are available on the canonical MDN page.
Browser compatibility
Browser compatibilityCompatibility data is available on the canonical MDN page.