CSSStyleDeclaration cssText property

Definition and usage

cssText Set or return the value of the inline (inline) style declaration of the element.

Instance

Example 1

Return the value of the inline style of the h1 element:

var elmnt = document.getElementsByTagName("h1")[0];
var x = elmnt.style.cssText;

Try it yourself

Example 2

Set the inline style declaration text of the element:

document.getElementById("ex1").style.cssText = "color: blue;";

Try it yourself

Syntax

Return cssText property:

element.style.cssText

Indstil cssText egenskab:

element.style.cssText = style

Tekniske detaljer

DOM version: Level 2 Style CSS
Returværdi: Streng, der angiver den inline stil for det angivne element.

Browser understøttelse

Chrome Edge Firefox Safari Opera
Chrome Edge Firefox Safari Opera
Support Support Support Support Support