Producing web pages
* HTML CSS DHTML XHTML A to Z of tags        Accessibility          Design

Check boxes

You use check boxes if you want a user to pick one or more options from a list. For example, a user may be able to ask for information on more than one product.

If you only want to select one option at a time, you should use radio buttons instead.

To set up a checkbox, use the <input> tag and set the type attribute to checkbox. A little example:

This HTML…

Displays as…

<form>
Would you like more information on?:
<input type="checkbox" value="0">Skis<br>
<input type="checkbox" value="1">Ski boots<br>
<input type="checkbox" value="2">Snowboards<p>
<input type="checkbox" value="3" checked>The lot
</input>
</form>

In our example, the The lot checkbox is pre-selected. A program to process the form can use the value attribute.

You can also use the name attribute to add an internal name to the field so the program that handles the form can identify the fields.