cssRules, CSSRuleList, rulesNN 6 IE 4 DOM 2  

  

A collection of cssRule (Netscape 6 and IE 5/Mac) or rule (IE 4 and later) objects that are members of a styleSheet object. The W3C DOM abstract representation of this collection is called a CSSRuleList object. Members of this collection are accessed only via their integer index number, but you may iterate through the collection and examine properties of each rule object (such as the selectorText property) to distinguish one rule from another.

 
Object Model Reference
 
IE (Windows)

document.styleSheets[i].rules

NN and IE (Mac)

document.styleSheets[i].cssRules

 
Object-Specific Properties
 
length
 
Object-Specific Methods
 
item( )
 
Object-Specific Event Handler Properties

None.

lengthNN 6 IE 4 DOM 2  

Read-only  

Returns the number of elements in the collection, including @ rules.

 
Example
 
var howMany = document.styleSheets[1].cssRules.length;
 
Value

Integer.

item( )NN 6 IE 4 DOM 2  

item(index)

  

Returns a style sheet rule object corresponding to the rule matching the index value in source code order.

 
Parameters
 
index

A zero-based integer corresponding to the specified item in source code order (nested within the current styleSheet object).

 
Returned Value

Reference to a cssRule or rule object, depending on the object model. If there are no matches to the parameters, the returned value is null.