Javascript Reference
Categories: window

javascript window getComputedStyle( )

@March 15, 2008, 1:22 a.m.
getComputedStyle( )Firefox/Netscape/NN 6 IE n/a Chrome/Safari/DOM 2  

getComputedStyle(elementNodeReference, "pseudoElementName")


Returns a style object (specifically, a CSSStyleDeclaration object in the W3C DOM terminology) showing the net cascade of style settings that affect the element passed as the first parameter. To retrieve a particular style attribute value (including a value inherited from the default browser style sheet), use the getPropertyValue( ) method of the style object returned from this method:

var compStyle = getComputedStyle(document.getElementById("myP"), "");
var pBGColor = compStyle.getPropertyValue("background-color");

See the style object for additional details.

  • Reference to an element node in the document tree that becomes the selection.
  • String name of a pseudo-element (e.g., :first-line) or an empty string.
Returned Value

style (CSSStyleDeclaration) object reference.

Powered by Linode.