AvailabilityDOM Level 2 CSS SynopsisCSSStyleDeclaration getComputedStyle(Element elt, String pseudoElt); Arguments
ReturnsA read-only CSSStyleDeclaration object (which typically also implements the CSS2Properties interface) that specifies the style information used to render the specified element in this view. Any length values queried from this object are always absolute or pixel values, not relative or percentage values. DescriptionAn element in a document may obtain style information from an inline style attribute and from any number of style sheets in the style-sheet "cascade." Before the element can actually be displayed in a view, its style must be "computed" by extracting style information from the appropriate parts of the cascade. This method allows access to those computed styles. By contrast, the style property of an element gives you access only to the inline styles of an element and tells you nothing about style-sheet attributes that apply to the element. Note that this method also provides a way to determine the actual pixel coordinates at which an element is rendered in this view. getComputedStyle( ) is actually defined by the ViewCSS interface. In any DOM implementation that supports the View and CSS modules, any object that implements AbstractView always implements ViewCSS also. So, for simplicity, this method has been listed with AbstractView. In Internet Explorer, similar functionality is available through the nonstandard currentStyle property of each HTMLElement object. See AlsoCSS2Properties, CSSStyleDeclaration, HTMLElement.style |