How to get and set CSS variable property values
suggest changeCustom property names are case-sensitive. element.style only sees inline declarations. A variable set in a stylesheet is read from the computed style.
element.style.setProperty("--var", "NEW_VALUE");
getComputedStyle(element).getPropertyValue("--var");
Found a mistake? Have a question or improvement idea?
Let me know.
Table Of Contents