Re: [csswg-drafts] [CSS2] Clarify margin collapsing behavior (#11306)

>It's the last scenario, when top and bottom margins of the same element collapse through it and combine into a single margin. 

Thank you for confirming—that’s exactly what I was seeking clarification on.

In my initial message, I proposed the following possible condition, quoting directly from the spec:

>A possible condition might be:

>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


Here’s the example again:

```html
<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <style>
      * {
        margin: 0;
        padding: 0;
      }

      .divs {
        background: lightgray;
        width: 600px;
        height: 60px;
      }
      .collapsed {
        background: lightpink;
        width: 600px;
        height:0;
        margin-top: 60px;
        margin-bottom: 30px;
      }      
    </style>
  </head>
  <body>
    <div class="divs" style="margin-bottom: 120px;"></div>
    <div class="collapsed"></div>
    <div class="divs" style="margin-top: 10px;"></div>
  </body>
</html>
```

In this example, `div.collapsed` clearly collapses into a single `margin-top:60px`.

My question is whether the `1st-div margin-bottom: 120px` collapses with the `3rd-div margin-top: 10px` by **collapsing through** `div.collapsed` combined margin? In other words, is it correct to say that `1st-div margin-bottom:120px` **passes through** (or **collapses through**) the combined margin-top: 60px of `div.collapsed` when it collapses with the `3rd-div margin-top: 10px`,  **Or** does the term **collapses through** refer only to the scenario where the margins of `div.collapsed` combine into a single margin, independent of the margins of its sibling elements?











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


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

Received on Monday, 2 December 2024 11:07:58 UTC