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 short
STYLE_RULE
= 1unsigned short
IMPORT_RULE
= 3unsigned short
MEDIA_RULE
= 4unsigned short
FONT_FACE_RULE
= 5unsigned short
PAGE_RULE
= 6unsigned short
NAMESPACE_RULE
= 10These are the possible values of the
type
property below and they specify what kind of rule it is. Iftype
is anything other than 1, the CSSRule object will have other properties that are not documented here.
Properties
string
cssText
The complete text of this CSS rule.
readonly CSSRule
parentRule
The rule, if any, within which this rule is contained.
readonly CSSStyleSheet
parentStyleSheet
The stylesheet within which this rule is contained. ...
Get JavaScript: The Definitive Guide, 6th Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.