Javascript Reference
Categories: cssRule

javascript cssRule Description

@March 15, 2008, 1:22 a.m.
cssRule, CSSRule, ruleFirefox/Netscape/NN 6 IE 5 Chrome/Safari/DOM 2  

  

A style sheet rule object is a member of the collection of styleSheet objects in the document. The IE and W3C DOMs have different syntax for referencing each of these rule objects. For IE, the reference is via the rules collection (a single object being known as a rule object); for W3C, as implemented in Netscape 6 and IE 5 for the Macintosh, the reference is via the cssRules collection (a single object being known as a cssRule object). Note that the cssRule object is not in the Windows version of IE through Version 6.

 

The corresponding W3C DOM abstract object is called the CSSRule object, but that form of the object name is important only to scripters who wish to modify the prototype properties and methods of the CSSRule object in Netscape 6. The W3C DOM goes further to define special types of CSSRule objects for each of the @ rule types (CSSImportRule, CSSMediaRule, and so on). A member of the cssRules collection can be any one of those types, and is identified as such by its type property. Each type has its own set of properties and/or methods that apply to that cssRule type. In the item property and method listings below, observe the type(s) for which they apply. By and large, however, the inline rules you will script are of the CSSStyleRule type.

 

Use scriptable access to a rule or cssRule object with caution. If you modify a rule's selector or style definition, the changes affect the entire document, and could, with a misplaced colon, ruin other rules in the document. To toggle among two or more styles for a single element, class, or element type, it is generally more reliable and efficient to use other techniques that work with multiple rules (swapping className assignments on elements) or multiple style sheets (enabling and disabling styleSheet objects). But for the sake of the completeness of the object model, the W3C DOM in particular provides full access to style sheet rule pieces if you absolutely need them.

 
Object Model Reference
 
document.styleSheets[i].rules[j]
document.styleSheets[i].cssRules[j]
 
Object-Specific Properties
 
cssRulescssTextencodinghref
mediaparentRuleparentStyleSheetreadOnly
selectorTextstylestyleSheettype
 
Object-Specific Methods
 
deleteRule( )insertRule( )
 
Object-Specific Event Handler Properties

None.

generic atorvastatin 20mg <a href="https://lipiws.top/">order lipitor 80mg online cheap</a> order lipitor for sale
Mxjopi - 9 months

Powered by Linode.