Re: [csswg-drafts] [css-pseudo] Add a ::contents pseudo-element (#2406)

One thing I was thinking about regarding the `::contents` — we probably don't want to create it for _every_ element by default.

And while the proposed “`::before` and `::after` being outside `::contents`” really unlocks various good use cases, I wonder if we'd want to have an ability to choose.

What if we had a non-inherited property that would enable the `::contents` on any element (and will do nothing on pseudo-elements), like (naming is probably the hardest) `enable-contents`. It would have an initial value of `none`, and a `normal` for what we could deem as the default behavior. Plus three values that include or exclude (based on that default behavior) `::after` and `::before` or both from the `::contents`.

The `::contents` pseudo-element will have `display: contents` by default, of course.

This won't affect any existing code, and we'd need to explicitly enable the pseudo-element on the elements where we'd want it. It would behave just as any other element, in that anything inside of it will inherit from it, not from the element itself. 

Someone could do `* { enable-contents: normal }` and get some weird consequences, but I don't think there is any reason to prevent this. But if we'd want to do so, then making the `::contents` _not_ to have `display: contents`, but be either `block` or `inline` by default could solve it (as this will obviously break almost everything when enabled on `*`).

I would be curious to know what are the potential issues (cascading or otherwise) with this kind of approach.

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


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

Received on Monday, 10 June 2024 22:23:28 UTC