HOME HTML CSS JAVASCRIPT SQL PHP JQUERY XML ASP.NET MORE...
REFERENCES | EXAMPLES | FORUM | ABOUT

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

Your suggestion:

Close [X]

Thank You For Helping Us!

Your message has been sent to W3Schools.

Close [X]
Search w3schools.com:

WEB BUILDING

Download XML Editor FREE Website BUILDER Free HTML5 Templates

SHARE THIS PAGE