HTML DOM Element offsetParent property

Definition and usage

offsetParent the property returns the position of the nearest ancestor that is not static.

If the element is not visible (display="none"), then offsetParent Property returns null.

See also:CSS Box Model Tutorial

offsetParent

All block-level elements report the offset relative to the offset parent:

  • offsetTop
  • offsetLeft
  • offsetWidth
  • offsetHeight

The offset parent refers to the nearest ancestor with a non-static position.

If the offset parent does not exist, the offset is relative to the main body of the document.

See also:

offsetTop property

offsetLeft property

offsetWidth property

offsetHeight property

Example

Get the offsetParent of "myDIV":

let node = document.getElementById("myDIV").offsetParent;

Try it yourself

Syntax

element.offsetParent

Return value

Type Description
Node The nearest ancestor with the most recent positioning.

Browser support

All browsers support element.offsetParent:

Chrome IE Edge Firefox Safari Opera
Chrome IE Edge Firefox Safari Opera
Support Support Support Support Support Support