Menu

1 / 5

CSS Typed OM: CSS values as objects, not strings

DEV Community: css·richi.codes·6 days ago
#nXfnD2gm
#devtocss#devto#dev#typed#value
Long article (1116 words) — no AI summary yet.
Reading 0:00
15s threshold

This note has an interactive demo. Try it in the original

Since Firefox 161 shipped on November 24, 2026, JavaScript in every major engine can read and write CSS as typed objects ( { value: 3, unit: "cm" } ) instead of strings like "3cm" . The CSS Typed Object Model has been in Chrome since version 66 and in Safari since 16.4. Firefox was the last one missing, so it's now Baseline.

It sounds like a small detail, and it mostly is. But anyone who has written el.style.width = size + 'px' and then parseFloat(getComputedStyle(el).width) to read it back knows how much glue code it replaces.

What it is and why it matters

The classic CSSOM speaks in strings. You build them by concatenating values and units, and you parse them back with parseFloat and a little hope. The Typed OM hands you objects instead. A length is a CSSUnitValue with a value and a unit . A calc() comes back as a CSSMathSum whose parts you can inspect. A keyword like auto is a CSSKeywordValue .…

Continue reading — create a free account

Join HashtagPLUS to read full articles, follow hashtags, vote, and join the conversation.