The Rules Collection

Note : The Rules collection is Internet Explorer 4.0 specific. As Netscape doesn't support dynamic style sheets, it doesn't support the Rules collection.

The Rules collection returns an indexed array of all the style rules in a referenced StyleSheet object. These are the style declarations for elements, classes, ids etc., set in the style sheet. The Rules collection is populated with references to style sheet rules regardless of whether or not the referenced style sheet is disabled, although any scripting changes to the rules will only become visible if the referenced style sheet is enabled. Any style sheets linked via the @import method will have their rules expanded in-place inside the rules collection.

Note that individual rules can only be added to a rules collection, by using the addRule method of the StyleSheet object.

Properties

length
The length property returns the number of rules in the collection. Note that the length count starts at 1, not 0 as the rules collection index does. Therefore, the length property may return a value of 5, but to access the 3rd rule, you'd need to use object.rules(2).property