Not to be confused with element-style CSSStyleDeclaration.cssText.
 

Summary

cssText returns the actual text of a CSSStyleSheet style-rule.

Note: Can no longer be set directly, as now specified to be functionally modify-only -- and *silently* so -- meaning that attempting to set it does absolutely *nothing* -- not even warn or error.  Further, it has no settable sub-properties.  Therefore, to modify, use the stylesheet's cssRules[index] properties .selectorText and .style (or its sub-properties).  See Using dynamic styling information for details.

Syntax

string = cssRule.cssText 

Example

<style>
body { background-color: darkblue; }
</style>
<script>
  var stylesheet = document.styleSheets[0];
  alert(stylesheet.cssRules[0].cssText); // body { background-color: darkblue; }
</script>

Specification

Browser compatibility

Update compatibility data on GitHub
DesktopMobile
ChromeEdgeFirefoxInternet ExplorerOperaSafariAndroid webviewChrome for AndroidEdge MobileFirefox for AndroidOpera for AndroidiOS SafariSamsung Internet
Basic supportChrome Full support 1Edge ? Firefox Full support 1IE ? Opera Full support YesSafari ? WebView Android Full support YesChrome Android Full support 18Edge Mobile ? Firefox Android Full support 4Opera Android Full support YesSafari iOS ? Samsung Internet Android ?

Legend

Full support  
Full support
Compatibility unknown  
Compatibility unknown

Document Tags and Contributors

Last updated by: jamessouth,