HTML DOM Element offsetParent Property
Example
Get the offsetParent of "myDIV":
let node = document.getElementById("myDIV").offsetParent;
Try it Yourself »
Definition and Usage
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:
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:
Syntax
element.offsetParent
Return Value
Type | Description |
Node | The nearest positioned ancestor. |
Browser Support
element.offsetParent
is supported in all browsers:
Chrome | IE | Edge | Firefox | Safari | Opera |
Yes | Yes | Yes | Yes | Yes | Yes |