CSSStyleDeclaration cssText attribute

Definition and usage

cssText Sets or returns 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 the cssText attribute:

element.style.cssText

Ställ in cssText-attribut:

element.style.cssText = style

Tekniska detaljer

DOM-version: Nivå 2 Style CSS
Returvärde: Sträng som representerar den inre stilen för den angivna elementet.

Webbläsarstöd

Chrome Edge Firefox Safari Opera
Chrome Edge Firefox Safari Opera
Stöd Stöd Stöd Stöd Stöd