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

Yes, this is a generic issue with BFCs - if a container is a BFC, margins can't collapse thru it; it it's not (as is the default for `display:block` with nothing else affecting it), margins can collapse thru. Columns are a "something else affecting it", and make the container into a BFC. You'll see the same behavior if the container is `float: left`, for example.

So yeah, depending on how you want to fix it, `margin-break` or `display:flow-root` are probably what you want.

* `margin-break` will cause the first margin to disappear in both cases (it doesn't actually collapse in the non-BFC case, so the container will still need a margin of its own)
* `display: flow-root` is identical to `block` except it forces a BFC, so it prevents collapse thru itself in all cases

`margin-break` isn't yet implemented anywhere iirc, tho.

Unfortunately, "fixing" this behavior would cause layout shifts on a *large* percentage of existing pages; it's about as guaranteed to not be web-compatible as we can get, I'd think.

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


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

Received on Thursday, 1 April 2021 22:32:12 UTC