Andreas Illg
KPCKevin Powell - Community
•Created by Andreas Illg on 10/28/2024 in #front-end
How to target the parent of selected text? Any workaround for ":has(::selection)"
I know, :has() does not work with pseudo-elements, but I like to style an element if it has parts of it selected. Just like :has(::selection) would do. Currently I am running a selectionchange handler on the document and check the list of parent candidates and attach a class "manually". But this should be doable with a css rule, right? Is there any workaround? Or is this planned to be implemented by the browsers?
1 replies