JavaScript getComputedStyle(): Get Computed Style of an Element
In this tutorial, you will learn how to use the JavaScript getComputedStyle() to get the computed CSS properties of an element. The getComputedStyle() method accepts two arguments: element is the element that you want to return the computed styles.It means that the computed styles are automatically updated when the styles of the element are changed. Let’s take some examples of using the getComputedStyle() method.Second, declare a paragraph element whose text color is red as defined in the inline style. This rule will override the one defined in the head section. Third, use the getComputedStyle() method to get all the computed styles of the paragraph element.The getComputedStyle() method returns a live style object which is an instance of the CSSStyleDeclaration object.