W3C home > Mailing lists > Public > www-style@w3.org > August 2010

[cssom-view] scrollWidth vs clientWidth

From: David Flanagan <david@davidflanagan.com>
Date: Mon, 16 Aug 2010 16:03:33 -0700
Message-ID: <4C69C3C5.2090500@davidflanagan.com>
To: www-style@w3.org

I cannot tell, from reading the spec, what the difference between the 
clientWidth and scrollWidth is supposed to be (and also clientHeight and 
scrollHeight, of course).

The scrollWidth is:

> the computed value of the padding-left property of A, plus the computed value of the padding-right  property of A, plus the content width of A. 

The clientWidth is:

> the viewport height excluding the size of a rendered scroll bar (if any) if the element is the root element and the height of the padding edge (excluding the width of any rendered scrollbar between the padding edge and the border edge) otherwise. 

I understand that for the root element clientWidth is the viewport width 
rather than the full content width, and I assume from that that 
clientWidth is supposed to exclude overflowing content and scrollWidth 
is supposed to include it.

Is my assumption correct?

I suppose that the CSS 2.1 specification must somewhere explain that the 
  "content width" of an element is different (in the case of overflow) 
than the width of the "content edge" of the element, but I can't figure 
out where it says that.

Perhaps you could add a non-normative green note to the spec to clarify 
the distinction between these two properties.

     David Flanagan
Received on Monday, 16 August 2010 23:04:19 UTC

This archive was generated by hypermail 2.4.0 : Friday, 25 March 2022 10:07:49 UTC