HTML DOM Element offsetParent Property

Example

Get the offsetParent of "myDIV":

let node = document.getElementById("myDIV").offsetParent;
Try it Yourself »

Description

The offsetParent property returns the nearest ancestor that has a position other than static.

The offsetParent property returns null if the element is not visible (display="none").

Tutorial:

CSS Box Model

The offsetParent

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

  • offsetTop
  • offsetLeft
  • offsetWidth
  • offsetHeight

The offset parent is the nearest ancestor that has a position other than static.

If no offset parent exists, the offset parent is the document body.

See Also:

The offsetTop Property

The offsetLeft Property

The offsetWidth Property

The offsetHeight Property


Syntax

element.offsetParent

Return Value

Type Description
NodeThe nearest positioned ancestor.

Browser Support

element.offsetParent is supported in all browsers:

Chrome Edge Firefox Safari Opera IE
Yes Yes Yes Yes Yes Yes

Copyright 1999-2023 by Refsnes Data. All Rights Reserved.