HTML and CSS Reference
In-Depth Information
Creating Reset Buttons
Reset buttons set all the form controls to their default values. These are the values
included in the
value
attributes of each field in the form (or in the case of selectable
fields, the values that are preselected). As with the Submit button, you can change the
label of a Reset button to one of your own choosing by using the
value
attribute,
like this:
<input type=“reset” value=“Clear Form” />
CAUTION
Reset buttons can be a source of some confusion for users.
Unless you have a really good reason to include them on your
forms, you should probably just avoid using them. If your form is
large and the user clicks the Reset button when he means to click
the Submit button, he isn't going to be pleased with having to go
back and reenter all of his data.
Creating Check Box Controls
Check boxes are fields that can be set to two states: on and off (see Figure 11.7). To cre-
ate a check box, set the
input
tag's type attribute to
checkbox
. The
name
attribute is also
required, as shown in the following example:
11
Input
▼
<label>
Check to receive SPAM email
<input type=“checkbox” name=“spam” /></label>
.
Output
FIGURE 11.7
A check box field.
To display the check box as checked, include the
checked
attribute, as follows:
<input type=“checkbox” name=“year” checked=“checked” />



