Element.computedStyleMap() is an instance method from the CSS Typed OM API. It returns a StylePropertyMapReadOnly of computed styles as typed values. Learn how it differs from getComputedStyle(), how to read properties with .get(), and five try-it labs. Support is Limited availability (not Baseline yet).
01
Kind
Instance method
02
Returns
StylePropertyMapReadOnly
03
Values
CSS Typed OM
04
vs getComputedStyle
Computed not resolved
05
Args
None
06
Status
Limited availability
Fundamentals
Introduction
For years, window.getComputedStyle(el) was the go-to way to read final CSS on an element. It returns a CSSStyleDeclaration full of strings —often resolved to pixels after layout.
computedStyleMap() is the Typed OM alternative. It returns a read-only map whose values are structured CSS objects. That makes it easier to process colors, lengths, and percentages programmatically—and it exposes computed values, which can differ from the resolved values getComputedStyle() returns.
💡
Beginner tip
Always feature-detect: typeof el.computedStyleMap === "function". When it is missing, fall back to getComputedStyle() for broad compatibility.
Calling el.computedStyleMap() takes no parameters and gives you a StylePropertyMapReadOnly—a map-like collection you can iterate or query with .get(propertyName).
It is an instance method on Element.
Returns computed values as CSS Typed OM objects, not strings.
Unlike getComputedStyle(), values are usually computed, not resolved.
For width: 50%, computed may stay 50% while resolved becomes pixels.
The map is read-only—you cannot set styles through it.
Part of the CSS Typed OM Level 1 specification.
Foundation
📝 Syntax
General form of Element.computedStyleMap (MDN):
JavaScript
computedStyleMap()
Parameters
None.
Return value
A StylePropertyMapReadOnly object containing computed CSS property/value pairs as typed values.
Common patterns
JavaScript
const el = document.querySelector(".item");
if (typeof el.computedStyleMap !== "function") {
console.log("computedStyleMap not supported");
} else {
const map = el.computedStyleMap();
// Read one property
const color = map.get("color");
console.log(String(color));
// Iterate all entries
for (const [prop, val] of map) {
console.log(prop, String(val));
}
}
Cheat Sheet
⚡ Quick Reference
Goal
Code
Get computed style map
el.computedStyleMap()
Read one property
map.get("width")
Loop all properties
for (const [p, v] of map) { … }
Feature detect
typeof el.computedStyleMap === "function"
Fallback
getComputedStyle(el).width
MDN status
Limited availability (not Baseline)
Snapshot
🔍 At a Glance
Four facts to remember about Element.computedStyleMap().
Element.computedStyleMap() is Limited availability on MDN (not Baseline). Strongest in Chromium browsers; Safari support is limited or missing on many versions. Logos use the shared browser-image-sprite.png sprite from this project. Always feature-detect.
✓ Limited availability · Not Baseline
Element.computedStyleMap()
CSS Typed OM computed styles — use getComputedStyle() as a fallback until coverage improves.
LimitedNot Baseline yet
Google ChromeSupported in Chromium browsers
Yes
Microsoft EdgeSupported (Chromium)
Yes
OperaSupported (Chromium mirror)
Yes
Mozilla FirefoxPartial / version-dependent
Partial
Apple SafariLimited or not supported — verify target versions
No
Internet ExplorerNot supported
No
computedStyleMap()Chromium-first
Bottom line: Use computedStyleMap() when you need typed computed values (especially percentages). Feature-detect and fall back to getComputedStyle() for portable string reads.
Wrap Up
Conclusion
Element.computedStyleMap() exposes computed CSS as a typed, read-only map. It complements—not replaces—getComputedStyle(), especially when you need computed percentages or structured values. Feature-detect and provide a fallback while support remains limited.
Confuse computed percentages with pixel layout results
Ship production code without a fallback path
Summary
Key Takeaways
Knowledge Unlocked
Five things to remember about Element.computedStyleMap()
Typed computed CSS — not the same as getComputedStyle strings.
5
Core concepts
📝01
Returns
MapReadOnly
API
📄02
Values
Typed OM
Format
✍️03
vs resolved
50% vs px
Width
✅04
Status
limited
Support
⚡05
Fallback
getComputedStyle
Portable
❓ Frequently Asked Questions
It returns a StylePropertyMapReadOnly — a read-only map of computed CSS properties on the element. Values are CSS Typed OM objects, not plain strings like getComputedStyle().
No. MDN lists it on the CSS Typed OM standard track with Limited availability (not Baseline). It is not marked Deprecated, Experimental, or Non-standard on MDN.
getComputedStyle() returns resolved values as strings (often pixels after layout). computedStyleMap() returns computed values as typed objects — for width: 50%, computed may stay 50% while resolved becomes pixels.
No. Call el.computedStyleMap() with no arguments.
Use map.get("property-name"), for example styles.get("color"). The result is a typed CSS value object — coerce to string for display if needed.
Feature-detect with typeof el.computedStyleMap === "function" and fall back to getComputedStyle() or other APIs.
Did you know?
For width: 50% inside a 200px container, getComputedStyle(el).width often returns 100px (resolved), while el.computedStyleMap().get("width") can still report 50% (computed). That is the main reason to choose Typed OM.