Element Properties: offsetLeft

By: Dusty Arlia
Published on Saturday, August 24, 2013, 12:22 PM
Last Updated on Tuesday, July 14, 2015 at 12:19 AM
Total Updates: 3

All HTML elements have the offsetLeft and offsetTop properties. The values of these properties are determined by the X, Y offset values of the current element and the parent offsetParent node. The X and Y values are calculated from the top-left corner of the current element in relation to the top-left corner of the offsetParent node which contains it. If the offsetParent property of the Element object is null, then the offsetTop and offsetLeft properties are document coordinates.

Here is offsetLeft's basic syntax:

var pixels_from_left_of_parent_element = element.offsetLeft;