w3c / csswg-drafts

CSS Working Group Editor Drafts
https://drafts.csswg.org/
Other
4.46k stars 657 forks source link

[css-pseudo-4] Add `user-select` to the list of applicable properties for styling highlights #8880

Open theseanl opened 1 year ago

theseanl commented 1 year ago

In the section https://drafts.csswg.org/css-pseudo-4/#highlight-styling, it lists a few CSS properties that are allowed to style highlights pseudo-elements, such as color, background-color. Also, it briefly mentions why only certain properties are allowed:

that do not affect layout and can be applied performantly in a highly dynamic environment

I suggest to add user-select to the list of applicable properties. With the advent of custom highlights of css-highlight-api-1 spec, it would allow use-cases such as making only a dynamically assigned portion a body of text selectable. The user-select property does not affect layout, and would be a good match with the highlight API for developers who want fine-grained control over how texts are highlighted.

frivoal commented 1 year ago

That seems doable, but I am not sure I understand why it is desirable. Can you give more examples of why you would selectively turn on of off part of the page based on highlights pseudos?