HTML and CSS Reference
In-Depth Information
product and submitting the form, the product number is what would be submitted to the
server.
Note In practice, all the options should consistently use or not use the value attrib-
ute.
Adding shorthand labels
Finally, we come to the label attribute. This attribute is designed to accept a short
value to use in lieu of displaying the content of an option . The label attribute can
be used to provide an alternative display label, while still retaining the original content
for the value passed to the server. The code for this looks like the following:
<select name="cheesemenu">
<option>Cheddar</option>
<option>Stilton</option>
<option>Brie</option>
<option label="All">All of the cheeses in all of the
worlds</option>
</select>
Adding menu structure
To help provide structure to your menus, you can use the optgroup element to group
similar option elements. So, instead of the following markup:
<select name="cheesemenu">
<option>- - - English cheeses - - -</option>
<option value="cheddar">Cheddar</option>
<option value="stilton">Stilton</option>
<option>- - -French cheeses- - -</option>
<option value="brie">Brie</option>
</select>
you would use this:
<select name="cheesemenu">
<optgroup label="English cheeses">
<option value="cheddar">Cheddar</option>
<option value="stilton">Stilton</option>
</optgroup>
<optgroup label="French cheeses">
Search WWH ::




Custom Search