Post #1522496
2026-02-20 17:34 UTC
@chriskirknielsen I see the benefit of the hover styles for a label triggering highlight on , but the selector I think is more useful is to select the label based on properties of the associated form element (like focus, required, invalid, etc.) without needing to worry about DOM structure. So that would be more like a label:for()
Feature request on the spec :
https://github.com/w3c/csswg-drafts/issues/1067
(The label itself should never be focused, so that's a problem with the spec example).
Replies (1)
-
@chriskirknielsen@front-end.social 2026-02-20 17:55
@AmeliaBR Yeah my mind first went to `label /for/ input:user-invalid` to make the label text bold/red/etc, but that's the other way around. What you linked to would allow that, I like it! I wonder if we could do `label:has(+ /for/ input:user-invalid)` as a workaround.