Skip to content

[CSS2] Adjoining margins when parent min-height is non-zero #2607

@mstensho

Description

@mstensho

https://www.w3.org/TR/CSS22/box.html#collapsing-margins

Given the following example:

<div id="parent" style="min-height:200px; background:skyblue;">
  <div id="child" style="height:50px; margin-bottom:100px;"></div>
</div>
<div id="successor" style="height:20px; background:salmon;"></div>

Should the bottom-margin of #child and #parent be considered to be adjoining? All the spec seems to have to say is that "bottom margin of a last in-flow child and bottom margin of its parent if the parent has 'auto' computed height" are adjoining. In this case the height is auto, so then they are adjoining. But it really makes no sense. It's pretty clear that those two margins aren't really adjoining. After all, the bottom margin of #child is in the middle of the border box of #parent, since it's stretched by min-height.

Currently, Chrome and Edge seem to follow the spec, and treat them as adjoining (and you get a white gap between #parent and #successor in the example above), while Firefox doesn't treat them as adjoining. What Firefox does makes a lot more sense, but it's not covered in the spec, as far as I can tell.

See also crbug.com/832016

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions