How to Add a Highlight Effect to Checked Input Field

This tutorial shows you an easy way to add a highlight effect to an input field that has been checked by the user. Not only is this a cool and different way to add some style to your sites, but it also improves user experience by making it pretty impossible for the user to accidentally check something they didn’t mean to.

Assuming your HTML looks something like this with an input field and a label tag:

Join us in our newest publication:

<input id="checkbox1" type="checkbox" />
<label for="checkbox1">Checkbox Label Text</label>

Then your CSS to add a highlighted effect to the label of any checkbox input that’s been checked should look like this:

input:checked + label{
 background: #e7f478; 
}

Screen Shot 2016-12-17 at 11.18.34 AM

As always, your choice of color that you use for the highlight effect is completely up to you, and this code can be customized completely to your liking.

Share and Enjoy !

0Shares
0 0