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.

css
@import "style1.css" supports(display: flex);
@import "style2.css" supports(selector(p:has(a)));
@import "style3.css";
js
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

Specification
CSS Object Model (CSSOM)
# dom-cssimportrule-supportstext

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
Chrome – Full support
Chrome 121 (Release date: 2024-01-23)
footnote Full support
Edge – Full support
Edge 121 (Release date: 2024-01-25)
footnote Full support
Firefox – Full support
Firefox 114 (Release date: 2023-06-06)
footnote Full support
Opera – Full support
Opera 107 (Release date: 2024-02-07)
footnote Full support
Safari – Full support
Safari 17.5 (Release date: 2024-05-13)
footnote Full support
Chrome Android – Full support
Chrome Android 121 (Release date: 2024-01-23)
footnote Full support
Firefox for Android – Full support
Firefox for Android 114 (Release date: 2023-06-06)
footnote Full support
Opera Android – Full support
Opera Android 81 (Release date: 2024-03-14)
footnote Full support
Safari on iOS – Full support
Safari on iOS 17.5 (Release date: 2024-05-13)
footnote Full support
Samsung Internet – Full support
Samsung Internet 25 (Release date: 2024-04-24)
footnote Full support
WebView Android – Full support
WebView Android 121 (Release date: 2024-01-23)
footnote Full support
WebView on iOS – Full support
WebView on iOS 17.5 (Release date: 2024-05-13)
footnote Full support

Legend

Tip: you can click/tap on a cell for more information.

Full support
Full support

See also