HTMLElement.offsetTop

The HTMLElement.offsetTop read-only property returns the distance of the current element relative to the top of the offsetParent node.

Syntax

topPos = element.offsetTop;

Parameters

  • topPos is the number of pixels from the top of the parent element.

Example

var d = document.getElementById("div1");
var topPos = d.offsetTop;
 
if (topPos > 10) {
  // object is offset more
  // than 10 pixels from its parent
}

Specification

Specification Status Comment
CSS Object Model (CSSOM) View Module Working Draft  

See also

Document Tags and Contributors

Last updated by: teoli,