Closed
Description
https://drafts.csswg.org/css-pseudo-4/#highlight-cascade
The UA must use its own highlight colors for ::selection only when neither color nor background-color has been specified by the author.
I think this sentence could be worded more precisely:
- Does “use” mean used value? This is mostly theoretical, because the spec doesn’t expose highlight pseudos to getComputedStyle, but I think it might affect what the devtools story looks like.
- Does “highlight colors” refer to a set of properties, and if so, which properties? My best guess is that color and background-color are included (because those are the ones with defaults in practice), and maybe stroke-color and fill-color too (wpt)? But what about text-{decoration,emphasis,shadow}?
- Do we really mean “for ::selection” only, or did we intend this for all highlight pseudos? The note suggests this rule exists for compatibility with existing ::selection impls, but ::target-text often has a default background-color too (see also [css-highlight-api] Need clarification on expected default values for style properties #6375).
- Do we really mean “neither color nor background-color” only, or any of the applicable properties? Note that the former would be inconsistent with existing impl behavior. For example, in Chrome and Firefox, setting text-shadow (even to none) also disables the usual default background-color (example).
- What does “specified by the author” mean? My best guess is that “specified by the author” means “cascaded value exists, and its origin was not the user agent”. Not specified as in specified value, which iiuc always exists due to defaulting (to transparent for background-color).
- How do we reconcile that with unset and revert? I feel like initial and inherit count as “specified by the author”, because the cascaded and specified values clearly exist for both, but for unset and revert, doesn’t it depend on whether we’re looking “before” or “after” they take effect?
- Do all properties become inherited for the purposes of deciding if unset should mean initial or inherit? I thought they did at first, but my Chromium colleagues have now convinced me that they don’t, given the “regardless” in “regardless of whether that property is an inherited property”.