W3cubDocs

/Web APIs

CSSImportRule: supportsText property

Baseline 2024
Newly available

Since ⁨May 2024⁩, this feature works across the latest devices and browser versions. This feature might not work in older devices or browsers.

The read-only supportsText property of the CSSImportRule interface returns the supports condition specified by the @import at-rule.

Value

A string, or null.

Examples

The document's single stylesheet contains three @import rules. The first declaration imports a stylesheet if display: flex is supported. The second declaration imports a stylesheet if the :has selector is supported. The third declaration imports a stylesheet without a supports condition.

The supportsText property returns the import conditions associated with the at-rule.

@import "style1.css" supports(display: flex);
@import "style2.css" supports(selector(p:has(a)));
@import "style3.css";
const myRules = document.styleSheets[0].cssRules;
console.log(myRules[0].supportsText); // returns `"display: flex"`
console.log(myRules[1].supportsText); // returns `"selector(p:has(a))"`
console.log(myRules[2].supportsText); // returns `null`

Specifications

Browser compatibility

Desktop Mobile
Chrome Edge Firefox Opera Safari Chrome Android Firefox for Android Opera Android Safari on IOS Samsung Internet WebView Android WebView on iOS
supportsText 121 121 114 107 17.5 121 114 81 17.5 25.0 121 17.5

See also

© 2005–2025 MDN contributors.
Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.
https://developer.mozilla.org/en-US/docs/Web/API/CSSImportRule/supportsText