CSSRule: cssText property
MDN Web Docs · نسخهٔ df622a2a1c1e · CC BY-SA 2.5 و مجوز جداگانهٔ ناشر برای نمونهکد
{{APIRef("CSSOM") }}
The **cssText** property of the {{domxref("CSSRule")}} interface returns the actual text of a {{domxref("CSSStyleSheet")}} style-rule.
توجه: Do not confuse this property with element-style {{domxref("CSSStyleDeclaration.cssText")}}.
Be aware that this property used to be mutable but is now read-only. Attempting to set it _does absolutely nothing_, and doesn't even emit a warning or error. Furthermore, it has no settable sub-properties. Therefore, to modify it, use the stylesheet's {{domxref("CSSRuleList", "cssRules[index]")}} properties {{domxref("CSSStyleRule.selectorText", ".selectorText")}} and {{domxref("CSSStyleRule.style", ".style")}} (or its sub-properties). See Using dynamic styling information for details.
Value
A string containing the actual text of the {{domxref("CSSStyleSheet")}} rule.
Examples
body {
background-color: darkblue;
}let stylesheet = document.styleSheets[0];
console.log(stylesheet.cssRules[0].cssText); // body { background-color: darkblue; }Specifications
{{Specifications}}
Browser compatibility
{{Compat}}