Style cssText Property

Style Object Reference Style Object

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 »

Definition and Usage

The cssText property sets or returns the contents of a style declaration as a string.


Browser Support

Internet Explorer Firefox Opera Google Chrome Safari

The cssText property is supported in all major browsers.


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 Reference Style Object

SHARE THIS PAGE

COLOR PICKER

colorpicker





Search w3schools.com:

Translate w3schools.com: