Re: [csswg-drafts] [CSS-Pseudo] Styling one-vs-many-vs-all with pseudo classes on highlight pseudos (#11727)

Considering what we would expect ::spelling-error:hover to do, I still think there are two possible author intents for @fantasai's example. Maybe the hover styling is intended to highlight which part of the word is misspelled, in which case the span structure is explicitly breaking the word into pieces. Or maybe the author wants to highlight the whole word on hover.

There are definitely use cases for both "apply hover to all instances" and "apply hover only to hovered" and I think we should somehow support both. I need to investigate exactly how the example about works in practice to understand whether we need the concept of groups to style the whole word when broken into spans, particularly when there are other misspelled words on the page.

From an implementation perspective, I can see ways to achieve "one or all" without tanking performance, but grouping is harder. In particular, while I can see ways to mark groups for custom highlights, it's not at all clear how to mark groups for spelling, grammar, URL fragments, search-text and other user agent generated markers.

Having said all that, two possible paths come to mind:
1. Go with "one or all" for now and see what authors do with it before trying to deal with "some". This would probably need to be `::spelling-error:hover:all` and `::spelling-error:hover:some`
2. Figure out some implicit grouping rule that works for spelling, grammar etc and add a grouping mechanism to the highlight API, plus still do option 1.

A custom highlight grouping rule could just be as simple as adding a group id to `CSS.highlights.set` and internlaly keying custom highlights off name and group together. And adding some keyword for specifying the group in CSS (kinda like view transitions, maybe).

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


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

Received on Wednesday, 25 June 2025 11:37:16 UTC