Firefox Tomorrow

web api instance method

CSSPrimitiveValue: setFloatValue() method

View on MDN ↗

The setFloatValue() method of the CSSPrimitiveValue interface is used to set a float value. If the property attached to this value can’t accept the specified unit or the float value, the value will be unchanged and a DOMException will be raised.

[!NOTE] This method was part of an attempt to create a typed CSS Object Model. This attempt has been abandoned, and most browsers do not implement it.

To achieve your purpose, you can use:

Syntax

setFloatValue(unitType, floatValue)

Parameters

Return value

None (undefined).

Exceptions

Type Description
DOMException An INVALID_ACCESS_ERR is raised if the CSS value doesn't contain a float value or if the string value can't be converted into the specified unit.
A NO_MODIFICATION_ALLOWED_ERR is raised if this property is read-only.

Specifications

This feature was originally defined in the DOM Style Level 2 specification, but has been dropped from any standardization effort since then.

It has been superseded by a modern, but incompatible, CSS Typed Object Model API that is now on the standard track.

Browser compatibility

Browser compatibilityCompatibility data is available on the canonical MDN page.