Just a few weeks until the 2021 JavaScript Full-Stack Bootcamp opens.
Signup to the waiting list!


Say you want to fetch the value of a CSS property in a web page, one that is set using a stylesheet.

The style property of an element does not return it, because it only lists CSS properties defined in inline styles, or dynamically.

Not the properties defined in an external stylesheet.

So, how do you do it? Use getComputedStyle(), a global function:

const element = document.querySelector('.my-element')
const style = getComputedStyle(element)
style.backgroundColor //the RGB value


The 2021 JavaScript Full-Stack Bootcamp will start at the end of March 2021. Don't miss this opportunity, signup to the waiting list!

More js tutorials: