Repository navigation
Expand file tree
/
Copy pathindex.md
More file actions
49 lines (34 loc) · 1.5 KB
/
Copy pathindex.md
File metadata and controls
49 lines (34 loc) · 1.5 KB
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
39
40
41
42
43
44
45
46
47
48
49
---
title: "CSSStyleProperties: cssFloat property"
short-title: cssFloat
slug: Web/API/CSSStyleProperties/cssFloat
page-type: web-api-instance-property
browser-compat: api.CSSStyleProperties.cssFloat
---
{{APIRef("CSSOM")}}
The **`cssFloat`** property of the {{domxref("CSSStyleProperties")}} interface returns the CSS {{cssxref("float")}} property.
This is the result of invoking {{DOMxRef("CSSStyleDeclaration.getPropertyValue()","getPropertyValue()")}} on the object with `float` as an argument.
When setting, it invokes {{DOMxRef("CSSStyleDeclaration.setProperty()","setProperty()")}} with `float` as the first argument, and the given value as the second argument.
The given value must be a valid value for the {{cssxref("float")}} property.
## Value
A string.
When set to the `null` value, that `null` value is converted to the empty string (`""`), so `csd.cssFloat = null` is equivalent to `csd.cssFloat = ""`.
## Example
In the below example, the stylesheet contains a single rule for `.box`, which has the {{cssxref("float")}} property with a value of `left`. This value will be returned by `cssFloat`. We then set the value to "right" using `cssFloat`, and return the new value.
```css
.box {
float: left;
inline-size: 300px;
}
```
```js
let myRules = document.styleSheets[0].cssRules;
let rule = myRules[0];
console.log(rule.style.cssFloat); // "left"
rule.style.cssFloat = "right";
console.log(rule.style.cssFloat); // "right"
```
## Specifications
{{Specifications}}
## Browser compatibility
{{Compat}}