Represents a style within a Cascading Style Sheets (CSS) that consists of a selector and one or more declarations.
Members Table
The following table lists the members exposed by the
rule
object. Click a tab on the left to choose the type of member you want to view.
Attributes/Properties
| Property | Description |
|---|
| readOnly |
Retrieves whether the rule or style sheet is defined on the page or is imported. |
| selectorText |
Retrieves a string that identifies which elements the corresponding style sheet rule applies to. |
Objects
| Object | Description |
|---|
| style |
Represents the current settings of all possible inline styles for a given element. |
Remarks
The rule object defines a set of CSS attributes applied to a set of HTML elements. For example, a rule consisting of the selector H1 and the declaration font-family:Arial defines all H1 elements to render in the Arial font.
This object is available in script as of Microsoft® Internet Explorer 5.
Examples
This example uses a rule object consisting of the selector H1 to define a single rule that changes the H1 heading(s) in a document to red.
<STYLE>
H1 { color: red }
</STYLE>
If the style sheet containing the preceding rule is the first style sheet in the document, the following code returns the rule object associated with the rule.
oRule=document.styleSheets(0).rules(0)
Standards Information
There is no public standard that applies to this object.
See Also
rules