May 03, 2021 HTML5
Html5 and optgroup tags are used to define a group of options that can be combined with options in a document. Please refer to this example below:
Put the relevant options together by using the hashtag:
<select>
<optgroup label="Swedish Cars">
<option value="volvo">Volvo</option>
<option value="saab">Saab</option>
</optgroup>
<optgroup label="German Cars">
<option value="mercedes">Mercedes</option>
<option value="audi">Audi</option>
</optgroup>
</select>
Most mainstream browsers support the hashtag.
The label is often used to group the relevant options together.
If you have a lot of options combined, you can use the hashtag to easily put the relevant options together.
No.
Property | Value | Describe |
---|---|---|
disabled | disabled | Provides that the option group is disabled. |
label | text | Specify a description for the option group. |
The label supports global properties and views the full property sheet HTML global properties.
The label supports all HTML event properties.