Deploy checkbox elements in a situation when the user must check all boxes that apply (or none). A scripting language such as PHP will easily handle this form element, returning all elements the user has checked (check out our PHP Form Example.)
HTML Checkbox Code:
<form name="myWebForm" action="mailto:youremail@email.com" method="post">
<p>Please select every sport that you play.</p>
Soccer: <input type="checkbox" name="sports" value="soccer" /><br />
Football: <input type="checkbox" name="sports" value="football" /><br />
Baseball: <input type="checkbox" name="sports" value="baseball" /><br />
Basketball: <input type="checkbox" name="sports" value="basketball" />
</form>
HTML Checkbox Form:
Please select every sport that you play. Soccer: Football: Baseball: Basketball:
Checkboxes are used for instances where a user may wish to select multiple options, such as in the instance of a "check all that apply" question.
HTML Checkboxes Selected
A checkbox element can be placed onto a web page in a pre-checked fashion by setting the checked attribute with a "yes" value. By doing so, this element will now default to a checked status each time the HTML page is loaded.