Re: [csswg-drafts] [css-pseudo-4] Add a highlight pseudo-element for find-in-page or scroll-to-text (#5233)

I did some research into additional use cases and considerations.

@tantek brought to my attention explorations like [Marginalia](https://indieweb.org/marginalia) from IndieWeb. The idea there is to use a fragment identifier to indicate responses or comments on sites. On that page, it suggests that "As a first step, marginalia can be displayed as normal post-level comments at the bottom of the post but with a reference/fragmentioned link to the context-phrase.". Such a UI would require the site's script to understand the fragment identifier and modify DOM accordingly; a pseudo-element is much too restrictive in expressivity. In that case a script-exposed state such as that proposed [here](https://github.com/WICG/scroll-to-text-fragment/issues/128), and/or a script event indicating highlighting as proposed [here](https://github.com/WICG/display-locking/blob/master/explainers/beforematch.md) would be make sense.

However, for simple styling of default User Agent affordances such as the color of the scroll-to-text highlight, it makes more sense to simply expose the highlight pseudo-element for this purpose, and specify which CSS properties apply to it. An alternative of requiring script to do it would be very difficult for page authors to implement, in part because it needs to happen very earlier in the page load lifecycle.

It's possible to imagine a User Agent that does not use *only* a highlight to indicate scroll-to-text (e.g. maybe there would be an overlay UI of some kind), but it seems unlikely that this would occur without a highlight, because a highlight + scrolling is a very effective and established way for a User Agent to indicate text on a page that the user is interested in and plays nicely with the style and layout concepts of the web.

I'd like to move for us to adopt a highlight pseudo for find-in-page and scroll-to-text. We could even add one for each, since as mentioned in the CSSWG meeting notes the use cases are different.

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


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

Received on Tuesday, 25 August 2020 00:24:11 UTC