Skip to content

Latest commit

 

History

History
16 lines (12 loc) · 357 Bytes

getStyle.md

File metadata and controls

16 lines (12 loc) · 357 Bytes
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'