interface
Stylepropertymap — CSS reference
Writable Typed OM map for declarations. It supports setting, deleting and clearing properties, and appending values for suitable list-valued properties. Mutation is not the same as editing the computed map. In Chromium 144, animation-name custom identifiers were rejected by set(); conventional style.setProperty succeeded. List appending was verified separately with animation-duration.
Formal Syntax & Structure
css syntaxcss
map.set("width", CSS.px(24))Working Example
Example Snippetcss
<!doctype html><html lang="en"><meta charset="utf-8"><title>StylePropertyMap</title><style>body{margin:8px;font:16px/20px sans-serif;color:black;background:white}#a{color:green}</style><body><p id="a">Sample text</p><p>Run once, then reload the page to repeat from the original state.</p><button id="run" type="button">Run example</button><pre id="result" aria-live="polite"></pre><script>const target=document.getElementById('a');const sheet=document.styleSheets[0];async function demo(){const m=target.attributeStyleMap;m.set("width",CSS.px(24));const first=m.get("width").value;m.delete("width");return [m instanceof StylePropertyMap,first,m.has("width")];}document.getElementById('run').onclick=async()=>{try{document.getElementById('result').textContent=JSON.stringify(await demo());}catch(e){document.getElementById('result').textContent=e.name+': '+e.message;}};</script></body></html>