HTML and CSS Reference
In-Depth Information
To permit the user to select multiple choices from a menu, add the multiple
attribute to the select element. For example, as an alternative to the check-
boxes in Example 2.26, this code can be used:
<p> I'm interested in:
<select name="interests" multiple>
<option value="aches"> Aches </option>
<option value="cakes"> Cakes </option>
<option value="fakes"> Fakes </option>
<option value="lakes"> Lakes </option>
<option value="rakes"> Rakes </option>
Figure 2.26a shows how a typical browser displays the two sample select
elements. Note how much of a diference adding the multiple attribute makes.
Without the attribute, the select element creates a drop-down menu that is
activated when the user clicks the control. he activated menu exists above
other page elements and overlaps them. Because of these diferences, web
developers oten use HTML tables to lay out the various elements of a form.
his is an acceptable exception to the rule that HTML tables should only be
used to mark up tabular information. When using tables, however, remember
that a form element may be inside a table cell (th , td) element, or that an entire
table element can be inside a form, but a form may not break a table. A form
element, for instance, cannot be a direct child of a table body (tbody) or table
row (tr) element.
Figure 2.26a: Single- and multiple-choice select elements
With the multiple attribute, the select element creates an open menu that
is aligned with the text it is embedded in. he select element is positioned so
that the baseline of its last item is aligned with the baseline of the surround-
ing text. By using various alternative clicks (which are device- and operating-
system-speciic), the user can select none, one, or many of the options.
Search WWH ::

Custom Search