ArchiveOrangemail archive

www-style.w3.org


(List home) (Recent threads) (197 other W3C lists)

Subscription Options

  • RSS or Atom: Read-only subscription using a browser or aggregator. This is the recommended way if you don't need to send messages to the list. You can learn more about feed syndication and clients here.
  • Conventional: All messages are delivered to your mail address, and you can reply. To subscribe, send an email to the list's subscribe (we seem to have lost it) address with "subscribe" in the subject line.
  • Moderate traffic list: up to 30 messages per day
  • This list contains about 20,385 messages, beginning Mar 2011
  • 12 messages added yesterday
Report the Spam
This button sends a spam report to the moderator. Please use it sparingly. For other removal requests, read this.
Are you sure? yes no

Why do overflow values other than 'visible' establish a new block formatting context?

Ad
Daniel Tan/BoltClock 1333337223Mon, 02 Apr 2012 03:27:03 +0000 (UTC)
In the following Stack Overflow question, we observe that applying 
overflow: hidden to a container element causes it to stretch to contain 
a floated image (assuming a default automatic height):

http://stackoverflow.com/q/9942026/106224

This is, of course, expected behavior. As stated in 
<http://www.w3.org/TR/CSS21/visuren.html#block...>, applying an 
overflow value other than 'visible' to a box creates a new block 
formatting context for the box and its contents. For a container without 
a specific height (i.e. it's automatic), this causes it to stretch 
vertically until it can fully contain all of its descendants, floated or 
otherwise.

This leads us to wonder: why is this so? I am under the impression that 
removing floats from normal flow will interfere with clipping and 
scrolling, but am not sure how exactly. I can't seem to find any 
previous threads in the mailing list that discuss the overflow property 
in particular.

To that end, we have opened another question, which can be found in the 
following link. Since this does not appear to be covered in the 
formatting model spec, we would be grateful if we could obtain an 
authoritative view on it, as it would only invite pure speculation 
otherwise:

http://stackoverflow.com/q/9943503/106224Quoting from the above question:

> The CSS2.1 spec mandates that overflow other than visible establish a
> new "block formatting context". This strikes me as odd, that a
> property whose obvious purpose is to hide overflow without affecting
> layout, actually does affect layout in a most major way.
>
> It seems like overflow values other than visible combine two
> completely unrelated features: whether a BFC is created and whether
> the overflow is hidden. It’s not like "overflow:hidden" is completely
> meaningless without a BFC: because floats historically can overflow
> their parent element, hiding the overflow without changing the layout
> seems sensible.Thanks in advance for any insights.
L. David Baron 1333337792Mon, 02 Apr 2012 03:36:32 +0000 (UTC)
On Monday 2012-04-02 11:24 +0800, Daniel Tan/BoltClock wrote:
> This leads us to wonder: why is this so? I am under the impression
> that removing floats from normal flow will interfere with clipping
> and scrolling, but am not sure how exactly. I can't seem to find any
> previous threads in the mailing list that discuss the overflow
> property in particular.Fundamentally, because if the spec didn't say this, then having
floats intersect with something that's scrollable would require the
browser to rewrap (around intruding floats) the contents of the
scrollable element every time it scrolls.  This is technically what
CSS 2.0 required, but it was never implemented, and it would have
been a huge problem for speed of scrolling.

-David
Daniel Tan/BoltClock 1333339443Mon, 02 Apr 2012 04:04:03 +0000 (UTC)
On 4/2/2012 11:35 AM, L. David Baron wrote:
> On Monday 2012-04-02 11:24 +0800, Daniel Tan/BoltClock wrote:
>> This leads us to wonder: why is this so? I am under the impression
>> that removing floats from normal flow will interfere with clipping
>> and scrolling, but am not sure how exactly. I can't seem to find any
>> previous threads in the mailing list that discuss the overflow
>> property in particular.
>
> Fundamentally, because if the spec didn't say this, then having
> floats intersect with something that's scrollable would require the
> browser to rewrap (around intruding floats) the contents of the
> scrollable element every time it scrolls.  This is technically what
> CSS 2.0 required, but it was never implemented, and it would have
> been a huge problem for speed of scrolling.
>
> -David
>This makes sense for 'auto' and 'scroll', but what about 'hidden'? The 
spec says that 'hidden' indicates that overflowing content is clipped, 
and that no scrolling UI should be provided for viewing content that 
gets clipped. Or is 'should' the keyword here, implying that a UA may in 
fact provide a means (scrolling or otherwise) to access content outside 
the clipping region?
Boris Zbarsky 1333339828Mon, 02 Apr 2012 04:10:28 +0000 (UTC)
On 4/2/12 12:02 AM, Daniel Tan/BoltClock wrote:
> This makes sense for 'auto' and 'scroll', but what about 'hidden'? The
> spec says that 'hidden' indicates that overflowing content is clipped,
> and that no scrolling UI should be provided for viewing content that
> gets clipped.While scrolling UI is not provided, the content is still scrollable 
programmatically, and a number of pages perform just such scrolling 
(e.g. by setting scrollTop on the relevant element).

-Boris
Daniel Tan/BoltClock 1343963998Fri, 03 Aug 2012 03:19:58 +0000 (UTC)
On 4/2/2012 11:35 AM, L. David Baron wrote:
> On Monday 2012-04-02 11:24 +0800, Daniel Tan/BoltClock wrote:
>> This leads us to wonder: why is this so? I am under the impression
>> that removing floats from normal flow will interfere with clipping
>> and scrolling, but am not sure how exactly. I can't seem to find any
>> previous threads in the mailing list that discuss the overflow
>> property in particular.
>
> Fundamentally, because if the spec didn't say this, then having
> floats intersect with something that's scrollable would require the
> browser to rewrap (around intruding floats) the contents of the
> scrollable element every time it scrolls.  This is technically what
> CSS 2.0 required, but it was never implemented, and it would have
> been a huge problem for speed of scrolling.
>
> -David
>Sorry to bring up this old thread. I'd completely forgotten about it. I 
do have something to clarify:

If the float is contained within an element whose overflow is other than 
visible, does it get clipped within that container element? If so, does 
the float affect any content that comes after the container element, or 
just the content that would have reflowed around it within the 
container? Or was none of this defined in CSS2.0?

It probably doesn't matter to implementers or authors anymore since it's 
been superseded, but I'm quite curious.
Home | About | Privacy