CSS Typed OM now works in every major browser engine. Firefox 161 shipped it on November 24, 2026, so Chrome, Safari and Firefox all support it. As a result, MDN now marks the API as Baseline 2026 Newly available.
So what does that mean for you? In short, you can stop parsing strings like "320px" in JavaScript. Instead, you get real objects with a number and a unit. This guide explains what the API does, how to use it, and what it still leaves out.
What Is CSS Typed OM?
CSS Typed OM (the CSS Typed Object Model) is part of the CSS Houdini family of APIs. It exposes CSS values as typed JavaScript objects rather than plain strings. For example, a width of 320 pixels becomes an object with value: 320 and unit: "px".
The idea is simple. The browser already stores CSS values in a structured form internally. The old CSSOM turns those values into strings for you, and then you parse them back. The CSS Typed OM Level 1 specification removes that round trip.
The main entry points are:
element.computedStyleMap()to read the final, computed values of an element.element.attributeStyleMapto read and write inline styles.CSSStyleRule.styleMapto work with rules inside a stylesheet.- Factory functions such as
CSS.px(),CSS.percent()andCSS.deg()to create values.
Why Firefox 161 Makes CSS Typed OM Baseline
Chrome has supported the API since version 66 in 2018. Safari followed in version 16.4 in March 2023. However, Firefox was the last engine missing, so the feature stayed in “limited availability” for years.
That changed with Firefox 161. According to the release notes, scripts can now read and write CSS values as typed objects through computedStyleMap() and attributeStyleMap. Mozilla tracked the work in bug 2089681.
Firefox 161 was a busy release, by the way. It also added the random() function, which we covered in our CSS random() function guide, and support for Compression Dictionary Transport.
The Problem With String-Based Styles
Most developers still read styles like this. First you call getComputedStyle(), then you parse the result, then you build a new string to write it back.
const box = document.querySelector('.box');
// Old way: strings in, strings out
const width = parseFloat(getComputedStyle(box).width); // "320px" -> 320
box.style.width = (width + 20) + 'px'; // back to "340px"
This works, but it has real costs. You must remember the unit. You must handle values like auto or calc() by hand. In addition, every write creates a string that the browser has to parse again. MDN notes that the typed approach is generally faster because it skips that work.
CSS Typed OM vs the Classic CSSOM
It helps to compare the two models side by side. Both read and write the same styles. However, they hand you very different kinds of data.
- Classic CSSOM:
element.styleandgetComputedStyle()return strings such as"16px"or"rotate(45deg)". - CSS Typed OM:
attributeStyleMapandcomputedStyleMap()return objects such asCSSUnitValueorCSSTransformValue. - Math: with strings you do the math yourself. With CSS Typed OM, methods like
add()andto()handle units for you. - Errors: a typo in a string fails quietly. In contrast, an invalid typed value throws a
TypeError, so bugs show up sooner.
In practice, you can mix both models in the same project. Use CSS Typed OM where you do unit math, and keep simple string writes where they are already clear.
How to Read Values With CSS Typed OM
Reading computed styles
To read the final value of a property, call computedStyleMap() on an element. Then use get() with a property name.
const box = document.querySelector('.box');
const styles = box.computedStyleMap();
const width = styles.get('width');
console.log(width.value); // 320
console.log(width.unit); // "px"
const display = styles.get('display');
console.log(display.value); // "block" (a CSSKeywordValue)
Notice that numbers come back as real numbers. Keywords come back as CSSKeywordValue objects. Therefore you no longer need parseFloat() or regular expressions to clean up a value.
Reading inline styles
The attributeStyleMap property works the same way, but only for styles set in the style attribute. It also supports has(), delete() and clear().
How to Write Values With CSS Typed OM
Writing is just as direct. You pass a typed value to set(), and the browser applies it without parsing a string.
const card = document.querySelector('.card');
card.attributeStyleMap.set('padding', CSS.px(16));
card.attributeStyleMap.set('opacity', CSS.number(0.8));
card.attributeStyleMap.set('rotate', CSS.deg(3));
// Strings still work when you need them
card.attributeStyleMap.set('display', 'grid');
The CSS.* factory functions cover every common unit. For instance, you get CSS.rem(), CSS.vw(), CSS.ms() and many more. Each one returns a CSSUnitValue.
Unit-Aware Math and Conversions
This is where the API really helps. Numeric values have methods such as add(), sub(), mul(), div(), min() and max(). They understand units, so mixed units produce a proper calc() expression.
const total = CSS.percent(50).sub(CSS.px(20));
console.log(total.toString()); // "calc(50% - 20px)"
document.querySelector('.panel').attributeStyleMap.set('width', total);
// Convert between compatible units
console.log(CSS.s(2).to('ms').value); // 2000
console.log(CSS.in(1).to('px').value); // 96
// Parse a string into a typed value
const gap = CSSNumericValue.parse('1.5rem');
console.log(gap.value, gap.unit); // 1.5 "rem"
Because of this, animation helpers and layout scripts written with CSS Typed OM become much shorter. Moreover, the code reads closer to the CSS you would write by hand.
Working With Transforms
Transforms are a classic pain point with strings. With the typed API, a transform is a list of components that you can build and inspect.
const transform = new CSSTransformValue([
new CSSTranslate(CSS.px(10), CSS.px(0)),
new CSSRotate(CSS.deg(45)),
]);
const badge = document.querySelector('.badge');
badge.attributeStyleMap.set('transform', transform);
console.log(transform.toString()); // "translate(10px, 0px) rotate(45deg)"
You can also read a transform back and loop over its parts. That makes it easier to change one function without rebuilding the whole string.
What CSS Typed OM Does Not Cover Yet
The API is now Baseline, but it is not complete. Keep these limits in mind before you rely on it:
- No color types. The color interfaces in the spec, such as
CSSColorValueandCSSRGB, are not supported in Firefox or any other browser. Treat color values like strings for now. - Custom properties need care. Values that reference custom properties come back as
CSSUnparsedValueobjects. Test how each browser returns them before you depend on a typed result. - Newly available, not widely available. Visitors on older Firefox versions will not have the API, so plan a fallback for now.
Feature Detection and Fallbacks
Since the feature only became Baseline in November 2026, a quick check before use is still wise. Fortunately, detection takes one line.
const hasTypedOM = 'attributeStyleMap' in HTMLElement.prototype;
function setWidth(el, px) {
if (hasTypedOM) {
el.attributeStyleMap.set('width', CSS.px(px));
} else {
el.style.width = px + 'px'; // fallback for older browsers
}
}
With this pattern, modern browsers get the cleaner path and older ones keep working. Later, once the feature becomes widely available, you can drop the fallback.
Using CSS Typed OM in WordPress Projects
Many WordPress plugins and block themes still use small scripts for sliders, sticky headers and progress bars. Those scripts often read sizes with getComputedStyle() and write them back as strings. These are good first candidates for CSS Typed OM.
Start small. Pick one helper that does a lot of unit math and move it behind a feature check. Then measure the result in your browser profiler. If you already use modern CSS such as scroll-driven animations, you may need less JavaScript for motion in the first place.
FAQ
Is CSS Typed OM supported in all browsers?
Yes, in current versions. Chrome and Edge have supported it since 2018, Safari since 16.4, and Firefox since version 161. Color value types are the main gap.
Does it replace element.style?
No. The style property and getComputedStyle() still work. The typed API is an extra option that gives you objects instead of strings.
Is it faster than string styles?
Generally, yes. It avoids building and parsing CSS strings. Still, real gains depend on your code, so measure before and after a change.
Do I need a polyfill?
Usually not. For CSS Typed OM, a simple feature check with a string-based fallback is enough for most sites today.
Conclusion
CSS Typed OM finally works across Chrome, Safari and Firefox. It lets you read, write and calculate CSS values as real objects instead of fragile strings. In addition, it brings unit-aware math, easy conversions and structured transforms.
For now, keep a fallback for older Firefox versions and avoid color types. Otherwise, it is a good time to clean up the string parsing in your front-end scripts.
Sources
Need Help With Your Website or Web App?
Swrice builds and customises WordPress sites, plugins and web apps. Whether you need an upgrade, a custom feature or a fix, our team can handle it for you.


Leave a Reply