Grouping Menu Items
Still another means of bringing added clarity to your forms is grouping items within a menu. This is done using the optgroup
element. Along with optgroup
, you also use the label
attribute in both the optgroup
opening tag and each individual item within that group (see Example 5-15).
Example 5-15. Using optgroup
to group options in a form menu
<select name="regions" size="14"><optgroup label="Western Region"><option value="Arizona" label="Arizona">Arizona</option><option value="California" label="California">California</option><option value="Colorado" label="Colorado">Colorado</option><option value="Nevada" label="Nevada">Nevada</option><option value="Texas" label="Texas">Texas</option><option value="Utah" label="Utah">Utah</option> ...
Get Spring Into HTML and CSS now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.