This page is Ready to Use

Notice: The WebPlatform project, supported by various stewards between 2012 and 2015, has been discontinued. This site is now available on github.

getPropertyPriority

Summary

Gets the priority of a property in a CSS style declaration.

Method of css/cssom/CSSStyleDeclaration/CSSStyleDeclarationcss/cssom/CSSStyleDeclaration/CSSStyleDeclaration

Syntax

var priority = declaration.getPropertyPriority(property);

Parameters

property

Data-type
String

The name of the CSS property.

Return Value

Returns an object of type StringString

A string that represents the priority if the property is explicitly set in this declaration block and has a specified priority specified, or null.

Examples

Gets the priority of the first rule in the stylesheet.

<head>
<style>
#aDiv {
    width:200px !important;
}
</style>
<script type="text/javascript">
var rule = document.styleSheets[0].cssRules[0];
var priority = rule.style.getPropertyPriority ("width");
alert (priority);
</script>
</head>

<body>
<div id="aDiv">This is a div.</div>
</body>

Notes

The priority of a CSS property is designated by, for example, the !important declaration.

Related specifications

DOM Level 2 Style
Recommendation

See also

Related articles

CSSOM

Related pages

Attributions