Files
30-seconds-of-code/snippets/getStyle.md
2020-09-15 21:52:00 +03:00

357 B

title, tags
title tags
getStyle browser,css,beginner

Returns the value of a CSS rule for the specified element.

  • Use Window.getComputedStyle() to get the value of the CSS rule for the specified element.
const getStyle = (el, ruleName) => getComputedStyle(el)[ruleName];
getStyle(document.querySelector('p'), 'font-size'); // '16px'