Re: [csswg-drafts] [css2][css-flow] Define the intrinsic sizing algorithm for block containers (#9120)

> The min-content size is just the maximum among the outer min-content sizes of each float or in-flow block-level child.

Is this accurate? On Firefox

```
<div style="width: min-content; border: 1px solid red; height: 0.5cm"></div>
```

shows up as 2px.

However changing it to 300px then constraining it to min-content it stays 300px:

```
<div style="max-width: min-content; width: min-content">
  <div style="width: 300px; border: 1px solid red; height: 0.5cm"></div>
</div>
```

The definition is simply recursive but I think the recursion edge is ambiguous and maybe because of that this definition skips over some things.

So, I know very little about the Firefox code base and I had to guess at a lot of types/utility methods/naming conventions but the min-content size but min-content size appears to be based on the min-content size of each child _overridden_ by style including margin, border, padding, and more importantly _width_: via https://searchfox.org/mozilla-central/source/layout/base/nsLayoutUtils.cpp#4657 https://searchfox.org/mozilla-central/source/layout/base/nsLayoutUtils.cpp#4520 (the previously calculated result is discarded in favor of the `width` value and 

So `width: 300px` doesn't modify an element's min-content size, but instead affects its _parent's_ min-content size if that parent is a normal block... FWIW to me this is both highly intuitive and is confusingly non local.  Also this seems fairly extrinsic, despite the name.

If I can sneak in a couple extra comments here,
- The spec I feel carefully describes `width` as the "preferred width" as if that width can be overridden by constraints, but per the above that doesn't appear to be correct - it might not affect `min-width` but it effectively introduces a minimum width.
- If this behavior can't be changed could new `preferred-width` and `preferred-height` properties be added which explicitly allow modifying the preferred width without affecting the intrinsic width? FWIW `grid` allows you to explicitly set preferred and min-content sizes using `minmax` so if one can replace their uses of block elements with grid elements that can be a workaround.

I apologize if I totally misread the codebase, but my reading of the code squares with the behavior I'm observing and given code comments and such I think the interpretation is at least mostly accurate... 

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


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

Received on Thursday, 17 April 2025 15:34:34 UTC