HTML and CSS Reference
In-Depth Information
figure 6-28
Order type selection list
selection list
Trouble? Depending on your browser, the selection list may appear slightly dif-
ferent from the one shown in Figure 6-28.
The first option in a selection list is the field's default value. To specify a different
default value and to display a different option from the selection list, add the selected
attribute to the option element as follows:
<option selected=”selected” value=” value ”> text </option>
Browsers also will accept the selected attribute without an attribute value, appearing
as follows:
<option selected value=” value ”> text </option>
However, this syntax is not supported in XHTML documents. To be consistent across
the different markup languages, this topic always includes an attribute value, even when
that attribute value does nothing more than repeat the attribute name.
Alice knows that most of the survey respondents dine in at the restaurant. Although
the options in the Order type selection list are displayed in alphabetical order, she would
like the Dine in option selected by default.
To specify the default value for the selection list:
1. Return to the survey.htm file in your text editor and add the
selected=”selected” attribute to the Dine in option (see Figure 6-29).
figure 6-29
specifying the selected option
the Dine in option
will appear selected
by default
2. Save your changes to the file and then reopen survey.htm in your Web browser.
Verify that the Dine in option is preselected in the order type list.
Setting the Size of the Selection List
By default, selection lists display only the currently selected option value. You can
change the number of options displayed by applying the size attribute
<select size=” value ”> ... </select>
Search WWH ::




Custom Search