-
Notifications
You must be signed in to change notification settings - Fork 22.4k
/
index.md
38 lines (25 loc) · 977 Bytes
/
index.md
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
---
title: "CSSStyleDeclaration: cssText property"
short-title: cssText
slug: Web/API/CSSStyleDeclaration/cssText
page-type: web-api-instance-property
browser-compat: api.CSSStyleDeclaration.cssText
---
{{APIRef("CSSOM")}}
The **`cssText`** property of the {{domxref("CSSStyleDeclaration")}} interface returns or sets the text of the element's **inline** style declaration only.
To be able to set a **stylesheet** rule dynamically, see [Using dynamic styling information](/en-US/docs/Web/API/CSS_Object_Model/Using_dynamic_styling_information).
Not to be confused with stylesheet style-rule {{domxref("CSSRule.cssText")}}.
## Value
A string containing the text of the element's inline style declaration.
## Example
```html
<span id="s1" style="color: red;"> Some text </span>
<script>
const elem = document.getElementById("s1");
alert(elem.style.cssText); // "color: red;"
</script>
```
## Specifications
{{Specifications}}
## Browser compatibility
{{Compat}}