This page is In Progress

Notice: The WebPlatform project, supported by various stewards between 2012 and 2015, has been discontinued. This site is now available on github.


Property of dom/HTMLElementdom/HTMLElement


var result = element.offsetLeft;
element.offsetLeft = value;


This example uses the offsetLeft property to determine whether an object is in the user’s view.

<script type="text/javascript">
function isinView(element) {
    var oparent = element.offsetParent;
    var osleft = oID_1.offsetLeft;
    var cleft = oparent.clientWidth;
    if (osleft > cleft) {
        alert("Expand the window to see the paragraph!");
<button onclick="isinView(this)">Click here</button>
<div id="oID_1" style="position: absolute; top:200px; left:1200px;">

View live example



You can determine the location, width, and height of an object by using a combination of the offsetLeft, offsetTop, offsetHeight, and offsetWidth properties. These numeric properties specify the physical coordinates and dimensions of the object relative to the object’s offset parent. For more information about how to access the dimension and location of objects on the page through the Dynamic HTML (DHTML) Document Object Model (DOM), see Measuring Element Dimension and Location with CSSOM in Internet Explorer 9.