Hacker News new | ask | show | jobs
by gluxon 2313 days ago
> If it doesn't have any absolutely positioned or floating child elements, wouldn't that imply contain: content?

I think the goal is to avoid analyzing child elements at all. So you can layout a given set of children at one layer of the DOM tree at once rather than having to dig deeper into one node to know where to put its sibling.

> And if you add overflow: auto or hidden, wouldn't that infer to contain: strict?

I think browsers would only be able to reasonable infer "contain: strict" on elements with both overflow auto/hidden and fixed width/height.

I'm guessing that "contain: strict" would allow you to avoid defining fixed height and width then? (That was just my first guess. There may be other reasons.)

1 comments

overflow: hidden/auto does not guarantee that children won't be painted outside of the element's bounds, even if it has a fixed width & height: https://codepen.io/vincentriemer/pen/WNvwpvQ

If you add contain: strict to the container in the above example you'll see that it then successfully clips the child div.