HTML and CSS Reference
In-Depth Information
9.8.1.1. The multiple attribute
To allow more than one option selection at a time, add the
multiple
at-
tribute to the
<select>
tag. This causes the
<select>
element to behave
like an
<input type=checkbox>
element. When submitted, the browser
collects the multiple selections, separated with commas, into a single
parameter list, such as:
pets=dog,cat,mouse
If you don't include the
multiple
attribute, the user may select only one
option at a time, just like in a group of radio buttons.
9.8.1.2. The size attribute
The
size
attribute determines how many options are visible to the user
at a time. The value of
size
should be a positive integer. The default
value is 1. When
size=1
without
multiple
, the browser typically displays
the
<select>
list as a pop-up menu. With
size
values greater than 1 or
with
multiple
, the browser typically displays the
<select>
element's con-
tents as a scrolling list.
In the following XHTML example, we've converted our previous check-
box example into a scrolling, multiple-choice menu. Notice that the
size
attribute tells the browser to display three options at a time:
[*]
[*]
Notice the
</option>
end tags. They are not usually included in standard HTML documents but
must appear in XHTML.
What pets do you have?
<select name="pets" size="3" multiple="multiple">
<option>Dog</option>
<option>Cat</option>
<option>Bird</option>