This page is Ready to Use

Notice: The WebPlatform project, supported by various stewards between 2012 and 2015, has been discontinued. This site is now available on github.

cssText

Summary

Gets or sets the textual representation of a CSS style declaration.

Property of css/cssom/CSSStyleDeclaration/CSSStyleDeclarationcss/cssom/CSSStyleDeclaration/CSSStyleDeclaration

Syntax

var declarationText = declaration.cssText;
declaration.cssText = declarationText;

Return Value

Returns an object of type StringString

The textual representation of the CSS style declaration.

Examples

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

Notes

This property reflects the current state of the declaration and not its initial value.

Related specifications

DOM Level 2 Style
Recommendation