Re: [csswg-drafts] [css-pseudo-5] ::text / ::text-node pseudoelement (#2208)

> So with this proposal you would actually need `a::text { display: none }`, and can't do different things for text nodes that precede or follow `i.fa`.

Correct, but you could still target the text node next to the icon via `a:has(> .fa)::text`.
Also, when adjacent sibling pseudo-element combinator suggested in #7346 becomes reality, one could write `i.fa :+ text` instead.

If we introduce a `::text` pseudo-element for that, I'd suggest to also add a functional version of it to target specific text nodes. That function takes an An+B notation to restrict it to specific nodes. So applying `p::text(1)` to the example in the initial comment would target the text node "Here is text".
Alternatively, we could define that the different `:nth-*()` pseudo-classes, when applied to text nodes, only refer to text nodes. So the first text node would then be targeted via `p::text:nth-child(1)`.

I also want to point out that this could be a potential performance footgun, because as @Loirooriol pointed out several times, `::text` means `*::text`, so it targets _all_ text nodes on a page. So authors might be inclined to define `::text { color: black; }` instead of `body { color: black; }` and relying on the cascade.

Sebastian

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


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

Received on Friday, 12 January 2024 20:57:41 UTC