Checkboxes in HTML

Checkboxes are used to select two or more optional items. If only one item needs to be selected, then it's better to use radio buttons.
How to create a checkbox element.
<input type="checkbox" parameters>
Field parameters are listed in table 1.
Table 1. Checkbox parameters.
Parameter | Description |
---|---|
name | Name of the field. Designed for the form handler to identify the field. |
value | The specified value of the field defines what will be sent to the server if the box element is checked. |
checked | If this parameter is present, then the box element will be checked automatically. |
Example 1 shows how to create and use checkboxes. Please note that the value of each box in the checkbox element differs. This way the server program can determine which item is checked.
Example 1. Using checkboxes.
<form action="/cgi-bin/handler.cgi"> <b>Which of the operating systems do you know?</b><br> <input type="checkbox" name="option1" value="a1" checked>Windows 95/98<br> <input type="checkbox" name="option2" value="a2">Windows 2000<br> <input type="checkbox" name="option3" value="a3">System X<br> <input type="checkbox" name="option4" value="a4">Linux<br> <input type="checkbox" name="option5" value="a5">X3-DOS </form>
The result is shown below.