W3cubDocs

/Web APIs

CSSStyleDeclaration: cssFloat property

The cssFloat property of the CSSStyleDeclaration interface returns the result of invoking CSSStyleDeclaration.getPropertyValue() with float as an argument.

When setting, it invokes CSSStyleDeclaration.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 float property.

Value

A string.

Example

In the below example, the stylesheet contains a single rule for .box, which has the 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

Browser compatibility

Desktop Mobile
Chrome Edge Firefox Internet Explorer Opera Safari WebView Android Chrome Android Firefox for Android Opera Android Safari on IOS Samsung Internet
cssFloat 1 12 1–17 9 ≤12.1 1 4.4 18 4–17 ≤12.1 1 1.0

© 2005–2023 MDN contributors.
Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.
https://developer.mozilla.org/en-US/docs/Web/API/CSSStyleDeclaration/cssFloat