label color change when radio input checked
Hi everyone
In this code:
with this structure, Is there any other way without using
has pseudo class to change the color of label when input hover/checked?13 Replies
The
input should be the child of labelWhy not use :has() ? It’s the right tool for the job
Yes. Just for curiosity and also the old browsers does not support. I wanna know Is there another way?
Currently I used
has as you seethe alternative is to move the input out of the label
then use the
for attribute
this way, you can use + instead
obviously, fix the tailwindWhich older browser versions are you needing to support ?
if i had to guess, probably old safari versions
some people avoid upgrading ios versions
at some point you just need to accept that progressive enhancements like label colors are only for people that take their own information security seriously enough to upgrade their browsers
As I see major browsers older than 2022 are not support and firefox older than 2023
Thanks. Yeah we can do this with
+ but with my structure can we do it?without
:has? nodo you have analytics for the site you're making? Cause without knowing how many users you'd actually be affecting, it's impossible to make a decision on whether to care about this or not
No. I'm just doing this project for practice and I was thinking what if we could not use
has in a project and if is there another way or not... As I understood with the same structure It's not possible but If the both label and input be siblings we can do it.I wouldn't worry about it at all in this case if I'm honest
a color shouldn't ever be vital information, so it's just presentation and that's fine to have as a progressive enhancement
quite apart from the fact that
:has has well over 90% support