HTML and CSS Reference
In-Depth Information
Both have the same value. The first is explicitly set within the <option>
tag; the second defaults to the content of the <option> tag itself: "Dog".
9.8.2.2. The selected attribute
By default, all options within a multiple-choice <select> tag are unse-
lected and therefore not included in the parameters list when the client
submits the form to the server. Include the selected attribute inside the
<option> tag to preselect one or more options, which the user may then
deselect.
The HTML version of the selected attribute has no value; the XHTML
version has the value selected="selected" . Single-choice <select> tags
preselect the first option if no option is explicitly preselected.
9.8.2.3. The label attribute
Normally, the browser creates a label from the contents of the <option>
tag when displaying it to the user. If the label attribute is supplied, its
value is used as the label instead.
9.8.3. The <optgroup> Tag
Menus of choices in forms can be quite large, making them difficult to
display and use. In these cases, it is helpful to group related choices,
which can then be presented as a set of nested, cascading menus to the
user. Introduced in HTML 4.0, the <optgroup> tag brings this capability
to HTML and XHTML forms, albeit in a limited way.
You can use the <optgroup> tag only within a <select> tag, and it may
contain only <option> tags. The browser creates submenus for each <op-
tgroup> tag within the main <select> menu.
 
Search WWH ::




Custom Search