style
style returns the declaration block for the current style.
Syntax
styleObj = cssRule.style
Parameters
styleObj is an object reference to the style declaration
Example
function stilo() { alert(document.styleSheets[0]. cssRules[0].style.cssText); } // displays "background-color: gray;"
Notes
The declaration block is that part of the style rule that appears within the braces and that actually provides the style definitions (for the selector, the part that comes before the braces).
Specification
DOM CSS Properties List
The following is a list of the CSS properties that are supported in the Netscape 6 DOM and accessible by means of the style property on elements.
The following complete document examples shows the typical use of the element.style property to get and set the CSS properties listed here:
Styles can be returned or set with the style property and these attributes but that you cannot set values directly using constructions such as style="background-color: blue" from the DOM, where the value is a string that contains both the attribute and the value you wish to set. By itself, the style property should only be used as a "getter" and not a "setter." In other words, the first of the following two constructions is bad, and the latter is better practice in the DOM:
Note that the bad example above may actually set the background color of the given element, but this assignment overwrites any style information that already existed on that element, and then cannot be added to or updated without other overwrites. The special style attributes available off of the element's style property allow you to "manage" the style of your elements in a safer and more organized way.
See also: the Element style property.
You can check the syntax for the values of these attributes by consulting the DOM CSS specification.
Netscape Communications http://developer.netscape.com |