About client- and offset- Properties

Internet Explorer 4 introduces a set of properties that have great potential for scripting the position and size of elements. The properties, which apply only to unpositioned elements, are:

clientHeight
clientLeft
offsetHeight
offsetLeft
clientWidth
clientTop
offsetWidth
offsetTop

The sad news is that it is impossible to know how to use these properties effectively. Microsoft’s developer documentation provides one set of definitions for the purposes of these properties, but, in practice, both the Windows 95/NT and Macintosh versions of Internet Explorer 4 not only disagree with much of the documentation, they disagree with each other.

The primary discrepancies have to do with whether an element’s margins, borders, and padding are included in the element’s various dimension and location measurements. In order to use these properties effectively in scripting the positions of elements, you need a stable measurement system. Unfortunately, except perhaps for the BODY element, these properties cannot be relied on without extensive testing in a specific application.

As an example of the mess that has developed, consider the values for clientHeight and clientWidth. The developer documentation asserts that these properties measure the element content only, exclusive of any margins, borders, or padding tacked onto the element. In IE 4 for Windows 95/NT, this assertion holds true for margins and borders, but not padding. Padding is not only ...

Get Dynamic HTML: The Definitive Reference now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.