Re: [csswg-drafts] [CSS Pseudo] Revisit CSS Custom Properties in highlight pseudos (#9909)

My understanding from @schenney-chromium's initial comment in this issue was that this is strictly a backwards-compatibility problem with the current `::selection` behavior, since the new highlight inheritance is a breaking change when applied to best practices around the current behavior.

That shouldn't be a blocker with CSS custom highlights since they've only ever used the new inheritance behavior. So I'm a little unclear on this point:

> It looks like custom properties specified on :root are applied, but nothing below that, even if it contains the entire element. That’s …very unfortunate and severely restricts use cases for this.
> 
> As an example, I was planning to base Prism v2 (one of the most popular syntax highlighters on the Web) on the CSS custom highlight API, and now I’m not even sure it's possible at all, since different languages need different colors so these cannot just be defined on the root.

This use case can still be realized by defining the colors on the `::highlight()` pseudos for elements below `:root`. This adoption of @LeaVerou's demo shows property definitions being scoped under particular elements: https://codepen.io/daniec/pen/MWRgENy. It's a little clunky but this kind of scoping is definitely possible.

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


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

Received on Tuesday, 27 February 2024 23:09:11 UTC