Re: [csswg-drafts] [css-multicol-1] Margin collapse of first-child element is unintuitive (#6170)

I don't think there's anything we should do here? A multicol container establishes a new formatting context, which prevents preceding / parent (in the example, that's BODY) margins from collapsing with child margins in the multicol. Just like e.g. `overflow:scroll` does.

```html
<!DOCTYPE html>
<div style="background:gray;">
  <div id="sibling" style="width:50%; margin-bottom:50px; height:10px; background:yellow;"></div>
  <div style="overflow:scroll; width:50%; height:200px; background:cyan;">
    <div id="nephew" style="margin-top:100px; height:400px; background:hotpink;"></div>
  </div>
</div>
```

The margins of `#sibling` and `#nephew` here don't collapse. That's the thing with formatting context roots - that they become a bit more "contained" or "isolated" than they would have been otherwise. Things inside a new formatting context cannot interact with floats and margins on the outside.

-- 
GitHub Notification of comment by mstensho
Please view or discuss this issue at https://github.com/w3c/csswg-drafts/issues/6170#issuecomment-2743015453 using your GitHub account


-- 
Sent via github-notify-ml as configured in https://github.com/w3c/github-notify-ml-config

Received on Friday, 21 March 2025 10:55:53 UTC