Language References
DOM Level 2 Specification.
Represents the current settings of inline styles for a given element.
Inline style information attached to elements is exposed through the style object.
Inline styles are CSS style assignments that an author applies directly to individual HTML elements using the style attribute. The style object is used to examine these assignments and either make new assignments or change existing ones.
The style object can be set or retrieved by applying the style keyword to any valid element object, followed by the corresponding CSS style property, as in the following notation.
To retrieve styles:
cssValue = element.style.cssProperty
To set styles:
element.style.cssProperty = "cssValue"
The style object does not give access to the style assignments in style sheets. To obtain information about styles in style sheets, you must use the styleSheets collection to gain access to the individual style sheets defined in the document.
The following properties are not available when the style object is accessed from the rule object: posHeight, posWidth, posTop, posLeft, pixelHeight, pixelWidth, pixelTop, and pixelLeft.
style Members
The following example sets the font for text in the document body to "Verdana."
document.body.style.fontFamily = "Verdana"
The following example positions the given image at the top of the document.
var i = document.all.tags ( "IMG" );
if ( i.length>0 ) {
if ( i[0].style.position == "absolute" )
i[0].style.top = 0;
}
styleSheet object, styleSheets collection