This feature is well established and works across many devices and browser versions. It’s been available across browsers since April 2021.
The read-only conditionText property of the CSSConditionRule interface returns or sets the text of the CSS rule.
A string.
The following example demonstrates reading the value of conditionText on a CSSMediaRule which implements the CSSConditionRule interface.
@media (width >= 500px) {
body {
color: blue;
}
}
const targetRule = document.styleSheets[0].cssRules[0]; console.log(targetRule.conditionText); // "(width >= 500px)"
| Desktop | Mobile | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Chrome | Edge | Firefox | Opera | Safari | Chrome Android | Firefox for Android | Opera Android | Safari on IOS | Samsung Internet | WebView Android | WebView on iOS | |
conditionText |
56 | 12 | 20 | 43 | 14.1 | 56 | 20 | 43 | 14.5 | 6.0 | 56 | 14.5 |
© 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/CSSConditionRule/conditionText