CSSMathProduct
Baseline 2026>
Newly available
*
Since November 2026, this feature works across the latest devices and browser versions. This feature might not work in older devices or browsers.
Want more browser support for this feature? Tell us why.
* Some parts of this feature may have varying levels of support.
Note: This feature is available in Web Workers.
The CSSMathProduct interface of the CSS Typed Object Model API represents the product of two or more CSSNumericValue values — in cases where the result can't be represented as a single value.
Constructor
CSSMathProduct()-
Creates a new
CSSMathProductobject.
Instance properties
Also inherits properties from its parent interface, CSSMathValue.
CSSMathProduct.valuesRead only-
Returns a
CSSNumericArrayobject which contains one or moreCSSNumericValueobjects.
Static methods
Also inherits methods from its parent interface, CSSMathValue.
Instance methods
Also inherits methods from its parent interface, CSSMathValue.
Description
A CSSMathProduct is produced whenever a multiplication or division can't be resolved to a single value.
This happens when any of the values is itself a calculation rather than a single unit value — for example, multiplying or dividing a sum such as 1px + 2%.
It also happens for a multiplication when more than one value has a unit, for example 10px * 20px or a length times a percentage, and for a division whenever a divisor has a unit, for example 10px / 2px or 10 / 2px.
mul() returns a single CSSUnitValue only if every value is a CSSUnitValue and all of them, or all but one, are plain numbers.
div() works the same way, except that every divisor must be a plain number.
Otherwise, both methods return a CSSMathProduct.
StylePropertyMapReadOnly.get() returns a CSSMathProduct the same way — for a calc() value that resolves to a multiplication or division it can't combine into one value.
CSSMathProduct represents the product expression itself, not a resolved value.
To get the resolved value, use getComputedStyle().
Examples
>Basic usage
The following code creates a CSSMathProduct instance from two values, then reads back its operator and values properties.
const product = new CSSMathProduct(CSS.px(10), CSS.percent(50));
console.log(product.constructor.name); // "CSSMathProduct"
console.log(product.operator); // 'product'
console.log(product.values); // CSSNumericArray {0: CSSUnitValue, 1: CSSUnitValue, length: 2}
console.log(product.values[0]); // CSSUnitValue {value: 10, unit: "px"}
calc() representations
This example shows how a calc() multiplication is represented by a CSSUnitValue or a CSSMathProduct, depending on whether it can be resolved to a single value.
HTML
<div id="demoBox">Text</div>
CSS
width is set using a calc() product of a length and a plain number, so the browser can resolve it to a single fixed value immediately.
font-size is set using a calc() product that multiplies a plain number by a parenthesized sum of 1rem and 5vw; since the sum itself can't be combined into a single value (it mixes units), the product can't either, and this will be represented by a CSSMathProduct.
#demoBox {
width: calc(10px * 2);
font-size: calc(2 * (1rem + 5vw));
}
JavaScript
First we find the demo box's style rule and read its width and font-size values using styleMap.
const demoBox = document.querySelector("#demoBox");
const rules = document.getElementById("css-output").sheet.cssRules;
const rule = [...rules].find((r) => r.selectorText === "#demoBox");
const styleMap = rule.styleMap;
const width = styleMap.get("width");
const fontSize = styleMap.get("font-size");
We then log the type and value of the CSS Typed OM representations, followed by the computed (resolved) values.
log("width");
log(` type: ${width.constructor.name}`);
log(` value: ${width}`);
log(` resolved: ${getComputedStyle(demoBox).width}`);
log("\nfont-size");
log(` type: ${fontSize.constructor.name}`);
log(` values: [${[...fontSize.values].join(", ")}]`);
log(` resolved: ${getComputedStyle(demoBox).fontSize}`);
Result
width is represented by a CSSUnitValue object, which has a value that matches the resolved width.
font-size is represented by a CSSMathProduct object that exposes the calc() product's original terms.
Specifications
| Specification |
|---|
| CSS Typed OM Level 1> # cssmathproduct> |