jeudi 8 décembre 2022

Is it possible to style a label with css based on the input elements "checked" status?

I have a number of [input type checkbox] with corresponding labels. The label/input are connected with the [for] property. I need to style the lable based on the [checked]-status of the checkbox. Can this be done WITHOUT a combinator as the structure makes using child/sibling combinators a poor choice.

Somthing along the lines of:

label[input:checked = "true"]{
color:pink;
}

Can this be done in a stable fashion with css or will I need to add/remove a classs with JS?

THX in advance :)

I have tried to write a selector that will target the label of a checked input element (type="checkbox").




Aucun commentaire:

Enregistrer un commentaire