HTML DOM Element offsetParent property
- Previous Page offsetLeft
- Next Page offsetTop
- Go to Parent Directory HTML DOM Elements Object
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:
Example
Get the offsetParent of "myDIV":
let node = document.getElementById("myDIV").offsetParent;
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 |
- Previous Page offsetLeft
- Next Page offsetTop
- Go to Parent Directory HTML DOM Elements Object