jQuery uses the offsetHeight and offsetWidth DOM attributes for
visible elements.  The w3c defines these attributes like so:

The offsetWidth  attribute, when called on element A, must  return
value that is the result of the following algorithm:

   1.      If element A does not have an associated CSS layout box
return zero and stop this algorithm.
   2.      Return the number of CSS pixels of the border box width of
element A.

The offsetHeight attribute, when called on element A, must return
value that is the result of the following algorithm:

   1.      If element A does not have an associated CSS layout box
return zero and stop this algorithm.
   2.      Return the number of CSS pixels of the border box height of
element A.

-- Quoted from http://www.w3.org/TR/cssom-view/#offset-attributes

I would take that to mean that border and padding SHOULD be included
if we wanted to be standards compliant.  Am I misunderstanding this?

On Mar 20, 9:56 pm, Rick <[EMAIL PROTECTED]> wrote:
> I think its because it is standards conforming to not to include
> padding/border.
> ie does include border/padding when using offsetHeight, most other
> browers dont.
>
> On 20 mrt, 20:16, Bryan Blakey <[EMAIL PROTECTED]> wrote:
>
> > On a particular project I'm working on, I noticed that when I use the
> >height() method on an element with padding, the element kind of
> > twitches, and the value returned is only theheightof the element
> > WITHOUT padding.  Looking into the code, thejQuery.css() function
> > sets all padding and border values to 0 before firing the swap
> > function to determine computed pixelheight/width.  This in effect
> > sets the css for the element momentarily to have no padding or border
> > before returning it to its original state, causing the weird twitch.
> > Is there a reason not to include the padding and border in the
> > computed width/heightof an element?  Seems incorrect to me, but maybe
> > I just don't know what I'm talking about...

Reply via email to