HTML Checkboxes

HTML checkboxes are just like radio buttons except you can select multiple values.

Example

Pizza: <input type="checkbox" name="food"/>
Chips: <input type="checkbox" name="food"/>
Pasta: <input type="checkbox" name="food"/>
Sponsored Links

Output

Pizza:
Chips:
Pasta:

The name attribute groups elements together.

Value Attribute

As before, there is no value with the checkboxes, so you put the value attribute to give each element a unique value.

Pizza: <input type="checkbox" name="food" value="pizza"/>
Chips: <input type="checkbox" name="food" value="chips"/>
Pasta: <input type="checkbox" name="food" value="Pasta"/>

Try It!

Pizza:
Chips:
Pasta:

 

Checked Attribute

The checked attribute will have the checkbox selected.

Example

Pizza: <input type="checkbox" name="food" value="pizza" checked="checked"/>
Chips: <input type="checkbox" name="food" value="chips"/>

Output

Pizza:
Chips: