HTML DOM offsetParent Property
THE WORLD'S LARGEST WEB DEVELOPER SITE

Element offsetParent Property

❮ Element Object

Example

Get the offsetParent for a <div> element:

var testDiv = document.getElementById("test");
document.getElementById("demo").innerHTML = testDiv.offsetParent;
Try it Yourself »

Definition and Usage

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

Note: offsetParent is used with the offsetLeft, and offsetTop properties.

Tip: offsetParent will return null if the element is set to display="none".


Browser Support

Property
offsetTop Yes Yes Yes Yes Yes

Syntax

Return the offsetParent of an element:

object.offsetParent

Technical Details

Default Value: no default value
Return Value: A Node object, representing nearest positioned ancestor
DOM Version: CSSOM

❮ Element Object