Movatterモバイル変換


[0]ホーム

URL:


  1. Web
  2. Web APIs
  3. CSSImportRule

CSSImportRule

Baseline Widely available *

This feature is well established and works across many devices and browser versions. It’s been available across browsers since ⁨July 2015⁩.

* Some parts of this feature may have varying levels of support.

TheCSSImportRule interface represents an@importat-rule.

CSSRule CSSImportRule

Instance properties

Inherits properties from its ancestorCSSRule.

CSSImportRule.hrefRead only

Returns the URL specified by the@import rule.

CSSImportRule.layerNameRead only

Returns the name of thecascade layer declared in the@import rule, the empty string if the layer is anonymous, the ornull if the rule doesn't declare any.

CSSImportRule.media

Returns the value of themedia attribute of the associated stylesheet.

CSSImportRule.styleSheetRead only

Returns the associated stylesheet.

CSSImportRule.supportsTextRead only

Returns the supports condition specified by the@import rule.

Instance methods

Inherits methods from its ancestorCSSRule.

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

css
@import "style.css" screen;
js
const myRules = document.styleSheets[0].cssRules;console.log(myRules[0]); // A CSSImportRule instance object

Specifications

Specification
CSS Object Model (CSSOM)
# the-cssimportrule-interface

Browser compatibility

Help improve MDN

Learn how to contribute

This page was last modified on byMDN contributors.


[8]ページ先頭

©2009-2025 Movatter.jp