Name
CSSRule — a rule in a CSS stylesheet
Description
A CSSRule object represents a rule in a CSSStyleSheet: it represents style information to
be applied to a specific set of document elements. selectorText is the string representation
of the element selector for this rule, and style is a CSSStyleDeclaration object that represents the set
of style attributes and values to apply to the selected
elements.
The CSS Object Model specification actually defines a hierarchy of CSSRule subtypes to represent different kinds of rules that can appear in a CSS stylesheet. The properties listed here are properties of the generic CSSRule type and of its CSSStyleRule subtype. Style rules are the most common and most important types of rules in a stylesheet, and the ones you are most likely to script.
In IE8 and before, CSSRule objects support only the selectorText and style properties.
Constants
unsigned shortSTYLE_RULE= 1unsigned shortIMPORT_RULE= 3unsigned shortMEDIA_RULE= 4unsigned shortFONT_FACE_RULE= 5unsigned shortPAGE_RULE= 6unsigned shortNAMESPACE_RULE= 10These are the possible values of the
typeproperty below and they specify what kind of rule it is. Iftypeis anything other than 1, the CSSRule object will have other properties that are not documented here.
Properties
stringcssTextThe complete text of this CSS rule.
readonly CSSRuleparentRuleThe rule, if any, within which this rule is contained.
readonly CSSStyleSheetparentStyleSheetThe stylesheet within which this rule is contained. ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access