You are here: Reference > JavaScript > client-side > style handling > methods > getPropertyValue

getPropertyValue method

Browser support:
Returns the value of the specified style property.
Note: The getPropertyValue method is supported in Internet Explorer from version 9.
In older Internet Explorer versions (and in newer ones as well), the getAttribute method provides similar functionality. Another possibility to retrieve the value of a CSS property is to use the corresponding JavaScript property. See the example below for details.
If you need to analyze the value of a style property, the getPropertyCSSValue method provides complex functionality in Firefox, Google Chrome and Safari.


object.getPropertyValue (propertyName);
You can find the related objects in the Supported by objects section below.


Required. String that specifies the name of the style property. This parameter is not case sensitive.

Return value:

Returns a string that identifies the value of the style property. If no property is specified with the given name, it returns an empty string in Firefox and Opera and null in Google Chrome and Safari.

Example HTML code 1:

This example illustrates the use of the getPropertyValue method:
    <script type="text/javascript">
        function GetBGColor (button) {
            // Works in all browsers
            alert (;

            if ( {
                alert ( ("background-color"));
            } else {
                alert ( ("backgroundColor"));
    <button onclick="GetBGColor (this);" style="background-color:red;">Get my background color!</button>
Did you find this example helpful? yes no

Supported by objects:

Related pages:

External links:

User Contributed Comments

Post Content

Post Content