Get The CSS Value Of A Property In Java Script
1 min read

CSS styles in JavaScript

Fetching CSS styles in JavaScript is quite easy, we need to use the getComputedStyle() global function.

const element = document.querySelector(".element");
const style = getComputedStyle(element);
style.color; // the value of the color