Re: [csswg-drafts] `display: contents` with `nth-child` and other pseudo-classes (#11647)

`:nth-child()` is purely based on the DOM, and `display: contents` only affects the box tree, not the DOM tree.

That would introduce all kinds of circularities, see https://wiki.csswg.org/faq#selectors-that-depend-on-layout

```html
<style>div:has(:first-child) > span { display: contents }</style>
<div><span></span></div>
```

If this considers the span to be the 1st child, then `display: contents` applies which would prevent it from being the 1st child according to your proposal, and thus `display: contents` would stop applying and it would become the 1st child again, and so on.

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


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

Received on Tuesday, 4 February 2025 22:41:18 UTC