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 style sheet.

Property of css/cssom/styleSheetcss/cssom/styleSheet

Syntax

var cssText = stylesheet.cssText;
stylesheet.cssText = cssText;

Return Value

Returns an object of type StringString

The textual representation of the style sheet.

Examples

This example uses the cssText property to retrieve the CSS style set on an object.

<p id="oPara" style="color: green; font-weight: bold;">
This is the test paragraph.</p>:
<button onclick="console.log(document.getElementById('oPara').style.cssText)">Get CSS attributes</BUTTON>

View live example

Notes

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

Related specifications

DOM Level 2 Style
Recommendation

See also

Related articles

CSSOM

Related pages

Attributions