Re: [csswg-drafts] Write up rationale for why selectors in values are discouraged (#12590)

Eh, Selectors don't impose a host-language dependence; CSS uses them just fine on any hypothetical host language.

The reasons we don't rely on selectors in values are more what @kbabbitt said - Selectors can get *really* expensive, really easily, and the full set of possible selectors (including, say, things like `:hover`) aren't necessarily appropriate for establishing a linkage. Authors certainly *can* depend on those sort of selectors anyway, writing rules like `foo:hover { anchor-name: --foo; }`, but at least there we already have a robust set of behavior for handling invalidation from selectors in rules. Having *more* invalidation needs come from the *values* on an element imposes a good bit more complexity.

Selectors are also a little more fragile than using names+scopes (but make up for it with directness). A lot of different markup patterns can still manage to define some name in some scope, and you can write code against that just depending on a name existing, rather than having to vary your selector in a property value for each pattern. It moves the complexity of establishing the linkage somewhere else (into rules), leaving the property value to be complex in other ways.

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


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

Received on Tuesday, 12 August 2025 21:12:42 UTC