CSS CSS Selectors Going Further with Attribute Selectors and Pseudo-Classes Element States Pseudo-Classes

Emmanuel Rojas
Emmanuel Rojas
6,994 Points

How Can I add any color to the check box after it is checked

How Can I add any color to the check box after it is checked. I was trying like this, but it do not work. Help!! pleace.

input[type="checkbox"]:checked { color: blue; }

1 Answer

Steven Parker
Steven Parker
182,269 Points

:point_right: Checkboxes and radio buttons don't have a color property, so they cannot be given a color that way.

A cute trick used by some of the popular CSS frameworks is to hide or cover the actual checkbox, and then trigger it with an associated label which is given a custom image. You can use this trick to just add color, or you could give your checkbox a radically different appearance.

:information_source: There are several websites that offer helper code for setting up these things. One of them is CSS Checkbox.