HTML: input type="checkbox"
A checkbox represents an independent choice that can be checked or left unchecked, such as agreeing to terms or selecting several interests.
What you will learn
- How to associate a label with a checkbox
- How name, value, and checked affect form data
- When checkboxes are better than radio buttons
Minimal example
<label>
<input type="checkbox" name="topics" value="css">
CSS
</label>When checked, the browser submits the field's name and value. An unchecked checkbox is normally omitted from the submitted form data.
Common mistakes
- Make the label clickable and explain what checking it means.
- Use radio buttons when exactly one option from a group is allowed.
- Do not treat the browser's checked state as proof of authorization or agreement; verify important choices on the server.