CSSStyleDeclaration.cssText

Not to be confused with stylesheet style-rule CSSRule.cssText.
 

Summary

cssText returns or sets the text of the element's inline style declaration only. To be able to set a stylesheet rule dynamically, see Using dynamic styling information.

Syntax

JavaScript
string = elem.style.cssText 

Example

JavaScript
<code><span id="s1" style="</code>color: red;"<code>>
Some text
</span></code>

<script>
  var elem = document.getElementById("s1");
  alert(elem.style.cssText); // { color: red; }
</script>

Specification

License

© 2016 Mozilla Contributors
Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.
https://developer.mozilla.org/en-us/docs/web/api/cssstyledeclaration/csstext