Private archive copy · Unofficial site · Content copyright belongs to Runoob Tutorial and the original authors · View Original

CSSStyleDeclaration cssText attribute

CSSStyleDeclaration cssText attribute

CSS CSSStyleDeclaration CSS CSSStyleDeclaration

Example

Return the inline style value of the h1 element:

var

elmnt

=

document

.

getElementsByTagName

(

"

h1

"

)

[

0

]

;

var

x

=

elmnt

.

style

.

cssText

;

Try it »


Definition and usage

The cssText attribute is used to set or return the inline style declared for the element.


Browser support

property
cssText Yes Yes Yes Yes Yes

Syntax

Return the cssText attribute:

element.style.cssText

Set the cssText attribute:

element.style.cssText = style


Technical Details

DOM version: Level 2 Style CSS
Return value: A string representing the inline style of the specified element.

More examples

Example

Set the inline style of the specified element:

document

.

getElementById

(

"

ex1

"

)

.

style

.

cssText

=

"

color: blue;

"

;

Try it »

CSS CSSStyleDeclaration CSS CSSStyleDeclaration