My FeedDiscussionsHeadless CMS
New
Sign in
Log inSign up
Learn more about Hashnode Headless CMSHashnode Headless CMS
Collaborate seamlessly with Hashnode Headless CMS for Enterprise.
Upgrade ✨Learn more

Accessing pseudo :root from IE

Emil Moe's photo
Emil Moe
·Aug 15, 2018

I am storing some default colors like this in my CSS

:root {
  --primary: #color;
}

Then I access it like this from JavaScript:

window.getComputedStyle(document.documentElement).getPropertyValue('--'+ color)

That works fine in Chrome and Firefox and Edge, but IE 11 doesn't get any value out. How can that be?

As far as I can see :root should be working in IE since version 9?