У w3schools есть хороший пост по этому поводу.
Немного изменив их пример, вы захотите заключить свой флажок в метку, элементы формы всегда должны иметь метки и дает вам возможность добавить необязательную текстовую метку (например, в скрипте).
<label class="checkbox-container">
<input type="checkbox" checked="checked">
<span class="checkbox-state"></span>
</label>
<label class="checkbox-container">
<input type="checkbox">
<span class="checkbox-state"></span>
</label>
<label class="checkbox-container">
<input type="checkbox">
<span class="checkbox-state"></span>
</label>
/* Customize the label (the container) */
.checkbox-container {
display: block;
position: relative;
margin: 10px;
cursor: pointer;
-webkit-user-select: none;
-moz-user-select: none;
-ms-user-select: none;
user-select: none;
}
/* Hide the browser's default checkbox */
.checkbox-container input {
position: absolute;
opacity: 0;
cursor: pointer;
height: 0;
width: 0;
}
/* Style the checkbox */
.checkbox-container input ~ .checkbox-state {
background-color: #fff;
border: 1px solid #ccc;
border-radius: 5px;
display: block;
width: 20px;
height: 20px;
}
/* Style the checkbox */
.checkbox-container input:checked ~ .checkbox-state {
background-color: #ccc;
}
Рабочая скрипка: https://jsfiddle.net/zano29jd/