Javascript Reference
Categories: cssRule

javascript cssRule style

@April 30, 2008, 8:09 a.m.
style Firefox/Netscape/NN 6 IE 5 Chrome/Safari/DOM 2  

 

Read/Write  

Returns a style object with properties that reflect the attribute settings of the current rule. This is the same kind of style object associated with elements in the document (corresponding to the W3C DOM CSSStyleDeclaration object). If you must modify style sheet settings at the rule level, do so via the style property of the rule or cssRule. Changes register themselves immediately, and the elements affected by the rule render their changes accordingly.

 
Example
 
var oneRule;
if (document.styleSheets) {
if (document.styleSheets[0].cssRules) {
oneRule = document.styleSheets[2].cssRules[1];
} else if (document.styleSheets[0].rules) {
oneRule = document.styleSheets[2].rules[1];
}
}
if (oneRule) {
oneRule.style.color = "red";
oneRule.style.fontWeight = "bold";
}
 
Value

Reference to a style (W3C CSSStyleDeclaration) object.

 
Default

Current style object.

 
W3C DOM CSSRule Types
 
CSSFontRule
CSSPageRule
CSSStyleRule

Powered by Linode.