[csswg-drafts] [css-sizing] How to handle min-content being bigger than max-context? (#12076)

Loirooriol has just created a new issue for https://github.com/w3c/csswg-drafts:

== [css-sizing] How to handle min-content being bigger than max-context? ==
There seems to be the assumption that the min-content size can't exceed the max-content size.

For example, [CSS Grid](https://drafts.csswg.org/css-grid/#minimum-contribution) has a note stating

> min-content contribution ≤ max-content contribution

However, consider this case:

```html
<!DOCTYPE html>
<style>span { display: inline-block; margin-right: -50px }</style>
<div style="width: min-content; border: solid">aaaaaaaaaaaa<span></span></div>
<div style="width: max-content; border: solid">aaaaaaaaaaaa<span></span></div>
```

When we avoid wrapping lines as per `max-content`, then the negative margin of the span makes the line shorter than when wrapping lines as per `min-content`! Browsers don't agree:

 - Firefox just allows `min-content` to be bigger than `max-content`
 - Blink ceils the min-content to not exceed the max-content
 - WebKit floors the max-content to be at least as big as the min-content
 - Servo is currently like Firefox but in a bunch of places we assume `min-content <= max-content`, leading to assert failures. I plan to align with WebKit for now, since typically in case of conflict CSS tends to choose the maximum amount.

| Firefox, Servo | Blink | WebKit |
| - | - | - |
| ![](https://github.com/user-attachments/assets/da458c5f-35ee-4890-9082-5e5deb64edf5) | ![Image](https://github.com/user-attachments/assets/886b82a2-ee7d-4f0a-b9b9-133d3f000a07) | ![](https://github.com/user-attachments/assets/6d724dda-7522-4d04-a60b-398c9fc6ec9f) |

Please view or discuss this issue at https://github.com/w3c/csswg-drafts/issues/12076 using your GitHub account


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

Received on Monday, 14 April 2025 16:13:18 UTC