Skip to content
Related Articles

Related Articles

Improve Article
CSSStyleDeclaration getPropertyValue() Method
  • Difficulty Level : Basic
  • Last Updated : 10 Apr, 2019

The getPropertyValue() method is used to return the value of the CSS property declared in the declaration block.



Parameters: It accepts a single parameter:

  • propertyname: It is a required parameter that contains a string which represents the name of the property to be checked.

Return Value: It returns a string which is used to represent the value of the property.

Example: To show the working of the getPropertyValue() method:

        body {
            text-align: center;
        h1 {
            color: green;
        #p1 {
            color: green;
            font-size: 20;
    <p id="p1">
      getPropertyValue() Method
    <button onclick="myFunction()">
        Get property value
    <p id="gfg"></p>
    <!-- Script to get the 
         property value-->
        function myFunction() {
            var x =
              "gfg").innerHTML =
                " Value of font-size: "
            + x.getPropertyValue("font-size");

Before clicking on the button:

After clicking on the button:

Supported Browsers:

  • Google Chrome
  • Internet Explorer 9.0
  • Firefox
  • Safari
  • Opera

My Personal Notes arrow_drop_up
Recommended Articles
Page :