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