The CSSStyleDeclaration.getPropertyValue() method interface returns a DOMString
containing the value of a specified CSS property.
var value = style.getPropertyValue(property);
property
is a DOMString
representing the property name to be checked.value
is a DOMString
containing the value of the property. If not set, returns the empty string.The following JavaScript code queries the value of the margin
property in a CSS selector rule:
var declaration = document.styleSheets[0].cssRules[0].style; var value = declaration.getPropertyValue('margin'); // "1px 2px"
Browser compatibility
Feature | Chrome | Edge | Firefox (Gecko) | Internet Explorer | Opera | Safari (WebKit) |
---|---|---|---|---|---|---|
Basic support | (Yes) | (Yes) | (Yes) | (Yes) | (Yes) | (Yes) |
Feature | Android | Edge | Firefox Mobile (Gecko) | IE Mobile | Opera Mobile | Safari Mobile | Chrome for Android |
---|---|---|---|---|---|---|---|
Basic support | (Yes) | (Yes) | (Yes) | (Yes) | (Yes) | (Yes) | (Yes) |
© 2005–2018 Mozilla Developer Network and individual contributors.
Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.
https://developer.mozilla.org/en-US/docs/Web/API/CSSStyleDeclaration/getPropertyValue