🚀 LEVEL UP TO SENIOR:Unlock 500+ Advanced Practical Challenges & Expert Masterclasses.
🎓 COURSERA PARTNER:Earn professional Google, Meta, and IBM certificates to supercharge your resume.
REFERENCEhtml

html Documentation

LOADING ENGINE...

HTML Checkboxes

Capture user choices with the checkbox input. Learn how to label, group, and pre-select options.

forms.html
<!-- Selection -->
<label for="opt">
Choose me
</label>
<input
type="checkbox"
id="opt"
>
☑️Interactive Demo
forms.html
1 / 10
☑️

Tutor:Checkboxes are used when you want to let the user select one or more options from a limited number of choices. Unlike radio buttons, checkboxes are independent—selecting one doesn't unselect others.


Form Mastery

Unlock nodes by mastering inputs.

Concept 1: The Tag

Checkboxes are created with <input type="checkbox">. This is a void element.

System Check

Is the checkbox input a void element?


Community Holo-Net

Showcase Your Forms

Built a complex preference center? Share your checkbox logic.

Enjoying this guide?

Codesyllabus is 100% free and open-source. Support our mission, pay for server infrastructure, and fuel new tutorials by buying us a coffee!

Mastering HTML Checkboxes

Author

Pascual Vila

Frontend Instructor.

The <input type="checkbox"> element is a fundamental part of web forms. It allows users to select multiple options from a set, or toggle a single setting on or off.

The Input Tag

Checkboxes are defined using the <input> tag with the type attribute set to "checkbox". Like other input elements, it is a void element and does not require a closing tag.

Labels and Accessibility

A checkbox without a label is a mystery to the user. Always associate a <label> with your input. You can nest the input inside the label, or use the for attribute (which must match the input's id) to connect them.

Attributes: Checked and Name

To pre-select a checkbox, simply add the checked boolean attribute. To group data when submitting a form, use the name attribute. All checkboxes with the same name will be submitted as an array of values.

Checkbox Glossary

Checkbox
A graphical control element that allows the user to make a binary choice (true/false) or select multiple options from a list.
checked
A boolean attribute. When present, it specifies that the input element should be pre-selected (checked) when the page loads.
Label
A caption for an item in a user interface. Clicking the label toggles the associated checkbox, increasing the hit area.
for / id
The mechanism to link a label to an input. The value of the for attribute on the label must match the id of the input.