HTML and CSS Reference
The <input /> tag creates an input control, while the attribute and value
type="checkbox" specifies that the input control is a check box. The name attribute of the
input control is set to the value musictype. When the form is submitted, the name is used
to distinguish the values associated with these checkbox fields from other fields. The value
attribute "country" indicates the value submitted in the file, if this check box is selected.
To Add Check Boxes
In the Web page form, six check boxes are used to allow the user to select one or more types of music to add.
Table 6-6 shows the HTML code to add six check boxes to the form.
Table 6-6 HTML Code to Add Check Boxes
HTML Tag and Text
<br />Select the type(s) of music that you prefer:
<br /><input name="musictype" type="checkbox" value="country" />Country
<input name="musictype" type="checkbox" value="folk" />Folk
<input name="musictype" type="checkbox" value="latin" />Latin
<input name="musictype" type="checkbox" value="pop" />Pop
<input name="musictype" type="checkbox" value="rap" />Rap
<input name="musictype" type="checkbox" value="rock" />Rock
The following step enters HTML code to add check boxes to the form.
Line 23 and indented one Tab stop.
Check that the insertion point is on
6-6 and then press the e n t e r key
twice (Figure 6-11).
Enter the HTML code shown in Table
on line 31 and
How do I determine whether to
list fields on the same line or use
a line break or paragraph break
Consider the “real estate” (the
amount of space available) of the
Web page itself. If you have an
especially long form that the visitor
has to scroll down, consider positioning the fields across, rather than down the form. You do
not want to crowd the information, but you also do not want to force the visitor to scroll excessively.
six check boxes
added to form
name value describes
input control type
set to checkbox
Adding Radio Buttons
The next step is to add radio buttons to the form. Remember that radio buttons are appropriate to use when
a user can select only one choice from a set of two or more choices. Although questions with a Yes or No answer are
perfect for the use of radio buttons, other types of questions are appropriate as well. In the case of selecting where
they make most of their music purchases, users are asked to select one choice from five options. On the Web page
form radio buttons allow users to select a one-choice answer to a question.