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

I see the problem.

Though this example won't work, even though my rationale says it should:

```html
<style>span:first-child { background: red }</style>
<div style="display: contents"><span></span></div>
<div style="display: contents"><span></span></div>
```

To avoid circularities, `display: contents` can be omitted if presented within a dom-based selector, which would solve the problem.

However you mentioned that `display: contents` is about the box tree, in this case, it makes sense.

---

<details>
<summary>Explanation why I needed that</summary>
I was looking for a way to contain elements within another element so that it would persist in the DOM, but won't be interacting in ANY way as if it's not there at all. So far I wasn't so lucky, I found only

- `all: inherit` - but works poorly with layouts (flex, grid)
- `display: contents` - but it's only about tree boxes
- `DocumentFragment` - but it's not attached to the dom

sigh
</details>

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


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

Received on Wednesday, 5 February 2025 06:16:36 UTC