Style cssText Property
Example
Set the style for a <p> element:
document.getElementById("myP").style.cssText = "background-color:pink;font-size:55px;border:2px dashed green;color:white;"
Try it Yourself »
Description
The cssText property sets or returns the contents of a style declaration as a string.
Browser Support
Property | |||||
---|---|---|---|---|---|
cssText | Yes | Yes | Yes | Yes | Yes |
Syntax
Return the cssText property:
object.style.cssText
Set the cssText property:
object.style.cssText = string
Value | Description |
---|---|
string | Specifies the content of a style declaration |
Technical Details
Default Value: | This property has no default value |
---|---|
Return Value: | A String, representing the text value |
DOM Version | DOM Level 2 |
More Examples
Example
Get the style declaration as a string:
alert(document.getElementById("myP").style.cssText);
Try it Yourself »
❮ Style Object