Coding With Fun
Home Docker Django Node.js Articles Python pip guide FAQ Policy

HTML <optgroup> tags


May 04, 2021 HTML Reference Manual


Table of contents


HTML slt;optgroup.gt; tags

The label is used to group the options provided by the element. W hen you use a longer list of options, combining related options makes processing easier.

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>

Try it out . . .

Browser support

HTML <optgroup> tags HTML <optgroup> tags HTML <optgroup> tags HTML <optgroup> tags HTML <optgroup> tags

Most mainstream browsers support the hashtag.


Label definition and instructions for use

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.


The difference between HTML 4.01 and HTML5

No.


Property

属性 描述
disabled disabled 规定禁用该选项组。
label text 为选项组规定描述。


Global properties

The label supports global properties and views the full property sheet HTML global properties.


The event property

The label supports all HTML event properties.


Related articles

HTML DOM Reference Manual: HTML DOM Option Group Object