Add a pointer cursor to labels on check boxes only

Hi there,

Is it possible to add a pointer cursor to labels of check boxes only?

I’ve tried:

label, input[type="checkbox"] {
    cursor: pointer;
}

but it seems to apply it to all labels.

Any ideas?
Thanks

The easiest way would be to apply a class to the label element

<label for="blah" class="label-checkbox"><input type="checkbox" id="blah" name="something" value="Yes"> Yes</label>

.label-checkbox { cursor: pointer; }

1 Like

That would be this part:-

Maybe apply a sibling selector.

1 Like

OR…
since MOST checkboxes come BEFORE the label you could use the adjacent selector

input[type="checkbox"], input[type="checkbox"] + label {
    cursor: pointer;
}

<input type="checkbox" id="check1" name="check1"><label for="check1">I'm check1</label>

hope that helps

1 Like

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.