Skip to content

[css2] Margins shouldn't collapse through replaced element #9006

@Loirooriol

Description

@Loirooriol
<!DOCTYPE html>
aaa
<canvas style="display: block; margin: 50px 0; height: 0px; min-height: 0"></canvas>
bbb

No browser lets the top and bottom margins of the replaced element to collapse through it.
The conditions are: https://drafts.csswg.org/css2/#collapsing-margins

  • both belong to in-flow block-level boxes that participate in the same block formatting context
  • no line boxes, no clearance, no padding and no border separate them
  • top and bottom margins of a box that does not establish a new block formatting context and that has zero computed min-height, zero or auto computed height, and no in-flow children

The interior of replaced elements is outside the scope of CSS, so I guess UAs might establish an independent formatting context if they want. But probably this shouldn't be left up to the UAs, the spec should explicitly handle replaced elements.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions