← HTML Fundamentals
Forms and accessibility · 15 MIN

Selects, checkboxes and radio buttons

Selects, checkboxes and radio buttons

Use select for a compact list of options, checkboxes for independent choices and radio buttons for one choice from a group. Give each control a meaningful label and group related controls with fieldset and legend.

Try it yourself

Change the example, run it, and explain the result in your own words. Then create one variation of your own.

Key idea

Use the example as a starting point, not something to memorize. Practise, inspect the result and make small improvements.

Code example

<fieldset><legend>Choose a track</legend>
<label><input type="radio" name="track" value="web"> Web</label>
<label><input type="radio" name="track" value="python"> Python</label></fieldset>