A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://developer.mozilla.org/en-US/docs/Web/API/CSSStyleDeclaration/getPropertyValue below:

CSSStyleDeclaration: getPropertyValue() method - Web APIs

CSSStyleDeclaration: getPropertyValue() method

Baseline Widely available

The CSSStyleDeclaration.getPropertyValue() method interface returns a string containing the value of a specified CSS property.

Syntax
getPropertyValue(property)
Parameters
property

A string representing the property name (in hyphen case) to be checked.

Return value

A string containing the value of the property. If not set, returns the empty string.

The property value is dynamically computed, not what was originally specified in the declaration. The serialization happens in the following way:

In essence, the property value is canonicalized, ensuring that two property values with the same rendering effect compare equal even when they are declared differently.

Examples

The following JavaScript code queries the value of the margin property in a CSS selector rule:

const declaration = document.styleSheets[0].cssRules[0].style;
const value = declaration.getPropertyValue("margin"); // "1px 2px"

The returned string might differ from the value specified in the style specification of the element. For instance this styling:

p#blueish {
  color: hsl(250 90 50);
}
const declaration = document.styleSheets[0].cssRules[0].style;
const value = declaration.getPropertyValue("color");

Will set a value rgb(51, 13, 242);. This is important when comparing styles by string.

Specifications Browser compatibility

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4