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 text 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

return value

type description
node the nearest ancestor of the most recent positioning.

browser support

all browsers support element.offsetParent

Chrome IE Edge Firefox Safari Opera
Chrome IE Edge Firefox Safari Opera
الدعم الدعم الدعم الدعم الدعم الدعم