Element offsetParent Property
Example
Get the offsetParent for a <div> element:
	<div id="test">
<p>Click the button to get the offsetParent for the test 
	div.</p>
<p><button onclick="myFunction()">Try it</button></p>
<p>offsetParent 
	is: <span id="demo"></span></p>
</div>
<script>
function myFunction() 
	{
    var testDiv = document.getElementById("test");
    
	document.getElementById("demo").innerHTML = testDiv.offsetParent;
}
	</script>
	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 | 12.0 | 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
