Attributes and accessibility
What attributes and labels does an HTML checkbox need?
Set name and value so a checked box sends a clear name=value pair, and use checked, disabled and required to control its starting state, whether it can be used and whether it must be ticked. The indeterminate state is set only in JavaScript (box.indeterminate = true): it draws a mixed dash for select-all controls but is not an HTML attribute and changes only the look, so the box still submits by its checked state. For accessibility, give every box a label with for/id or by wrapping it, and group related boxes in a fieldset with a legend so screen readers announce what the group is for.
| Attribute or pattern | What it does | Submission and accessibility effect |
|---|---|---|
name | The key the box is submitted under. | A named, checked and enabled box sends name=value; a box without a name is never submitted. |
value | The value sent when the box is checked. | Defaults to on when omitted, so set a meaningful value to tell answers apart. |
checked | Marks the box ticked in the HTML. | Sets the starting state and what form.reset() restores; it does not track later user toggles. |
disabled | Greys out the box and blocks interaction. | A disabled box is skipped on submit even when it is checked. |
required | Requires this box to be ticked before submit. | Blocks submission until ticked; it requires that one box, not one of a group. |
<label for="id"> or a wrapping <label> | Gives the box its accessible name and makes the text toggle it. | Clicking the label toggles the box; without a label a screen reader announces an unnamed checkbox. |
A fieldset + legend around a group of related boxes is the accessible way to caption the group — better than a plain heading.
Sources: WHATWG HTML Standard: checkbox state · WHATWG HTML Standard: indeterminate · MDN: input type=checkbox · MDN: label element