HTML <optgroup> (Option Grouping) Tag

❮ Previous Home Next ❯

Example

<select>
  <optgroup label="Group 1">
    <option>Option 1.1</option>
  </optgroup>
  <optgroup label="Group 2">
    <option>Option 2.1</option>
    <option>Option 2.2</option>
  </optgroup>
  <optgroup label="Group 3" disabled>
    <option>Option 3.1</option>
    <option>Option 3.2</option>
    <option>Option 3.3</option>
  </optgroup>
</select>

Meaning

The <optgroup> element specifies a grouping of items in a selection list defined by option elements so that the menu choices can be presented in a hierarchical menu or similar alternative fashion to improve access through nonvisual browsers.

Notes:

Version: HTML 4, 4.01, 5


Standard Syntax

<select>
  <optgroup label="text">
    <option>text</option>
  </optgroup>
</select>



Browser Support




Status







Attributes

Attribute Value Description
disabled disabled It's a Boolean attribute specifies that an option-group should be disabled
label text Specifies a label for an option-group



Global Attributes

<optgroup> element also supports the Global Attributes in HTML.


Event Attributes

<optgroup> element also supports the Event Attributes in HTML.




By Default CSS Value(s)

None.




Related Tags:

<button>, <datalist>, <fieldset>, <form>, <input>, <label>, <legend>, <meter>, <optgroup>, <option>, <output>, <progress>, <select> and <textarea>
❮ Previous Reference Next ❯