W3C home > Mailing lists > Public > www-style@w3.org > April 2008

RE: [cssom-view] padding edge / border edge for offsetTop/offsetLeft?

From: Mike Wilson <mikewse@hotmail.com>
Date: Fri, 25 Apr 2008 16:58:24 +0200
Message-ID: <BAY116-DAV129273D41145C24C301950A4DD0@phx.gbl>
To: "'Sylvain Galineau'" <sylvaing@microsoft.com>
Cc: "'Www-style'" <www-style@w3.org>
Message-ID: <00af01c8a6e4$cfb55160$0a01a8c0@mikedeskxp>

> This may be a very basic question so I hope you bear with me. 
> There is something I do not grok about measuring offsetLeft 
> from the parent's left padding edge to the element's own left 
> border edge, as defined in CSSOM-View:

I'd say there are two reasons for this behaviour:

1) IE does it this way.

2) It's compatible with CSS 2.1's positioning with left/top
   attributes for position:absolute elements.
   I e, if you have an absolutely positioned element that
   you assign 
     left:10px 
   to, then offsetLeft will also return 10 as the offset is
   measured from the same points (padding edge to border edge)
   as used by CSS positioning. Of course assuming here that the
   offsetParent and Containing Block elements are the same,  
   which they usually are in standards-mode IE, but not in the
   current CSSOM proposal.

> adding up offsetLeft 
> values defined this way up the offsetParent chain will 'miss' 
> the border for each element along the chain, resulting in an 
> incomplete aggregate offset.

This is of course only a problem if the elements have border>0
and is a problem that would have appeared for IE users a long
time ago if pages depended on it. And as Garrett showed there
are scripts that correctly add border and scroll.

Best regards
Mike Wilson
Received on Friday, 25 April 2008 14:59:14 GMT

This archive was generated by hypermail 2.2.0+W3C-0.50 : Monday, 27 April 2009 13:55:05 GMT