Re: [csswg-drafts] [selectors] `/idref()/` combinator to follow element references for arbitrary IDREF attributes (#10970)

> > What happens if `e1 /idref(for)/ e2` references a parent e1 descends ?
> 
> Going by [the current spec](https://drafts.csswg.org/selectors-5/#idref-combinators) for this:

Oh interesting, I hadn't noticed this was in the draft. I just opened #12451 to get a formal resolution that we'll use the slash syntax for all new combinators, which means that needs to become less generic.

But yes, to answer the initial question, `/idref(for)/` is unaffected by other tree relationships. So, for labels, to get all labels one would need something like `label /idref(for)/ *, label:not([for]) :is(input, select, textarea, ...)`, which is awkward but I think it's worth the flexibility of not tying this to HTML form semantics. We could later add a shortcut that is specific to form elements (and/or a pseudo-class to target all form associated elements, including custom elements).

Another thing to resolve is whether it can reference `e1` itself, which can be argued either way.

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


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

Received on Sunday, 6 July 2025 15:52:01 UTC