CSS Checkbox

How to change checkbox style using CSS

by Ayyappan Sakthivadivel

HTML

<div>
    <input type="checkbox" id="checkbox1" name="checkbox[]"/>
    <label for="checkbox1">Checkbox 1</label><br>
    <input type="checkbox" id="checkbox2" name="checkbox[]"/>
    <label for="checkbox2">Checkbox 2</label>
</div>

CSS

@import url(//netdna.bootstrapcdn.com/font-awesome/3.2.1/css/font-awesome.css);

input[type=checkbox] + label:before {
    font-family: FontAwesome;
    display: inline-block;
    font-size: 19px;
}

input[type="checkbox"]{
    appearance: none;
    -moz-appearance: none;
    -webkit-appearance: none;
    border: 1px solid #c8c6c6;
    width: 15px;
    height: 15px;
    border-radius: 2px;
    margin: 0 5px 0 0;
}

input[type="checkbox"]#checkbox1:checked{
    background: red;
}

input[type=checkbox]#checkbox2 {
    display: none;
}

input[type=checkbox]#checkbox2 + label:before { 
    content: "\f096"; 
    letter-spacing: 10px;
}

input[type=checkbox]#checkbox2:checked + label:before {
    content: '\f046';
}

input[type="checkbox"]:focus{
    outline: none;
}