Please note, this is a STATIC archive of website developer.mozilla.org from 03 Nov 2016, cach3.com does not collect or store any user information, there is no "phishing" involved.

Наши волонтёры ещё не перевели данную статью на Русский. Присоединяйтесь к нам и помогите закончить эту работу!

Summary

In a Web form, the HTML <optgroup> element  creates a grouping of options within a <select> element.

Content categories None.
Permitted content Zero or more <option> elements.
Tag omission The start tag is mandatory. The end tag is optional if this element is immediately followed by another <optgroup> element, or if the parent element has no more content.
Permitted parent elements A <select> element.
DOM interface HTMLOptGroupElement

Note: Optgroup elements may not be nested.

Attributes

This element includes the global attributes.

disabled
If this Boolean attribute is set, none of the items in this option group is selectable. Often browsers grey out such control and it won't receive any browsing events, like mouse clicks or focus-related ones.
label
The name of the group of options, which the browser can use when labeling the options in the user interface. This attribute is mandatory if this element is used.

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>

Result

Specifications

Specification Status Comment
WHATWG HTML Living Standard
The definition of '<optgroup>' in that specification.
Living Standard  
HTML5
The definition of '<optgroup>' in that specification.
Recommendation  
HTML 4.01 Specification
The definition of '<optgroup>' in that specification.
Recommendation  

Browser compatibility

Feature Chrome Firefox (Gecko) Internet Explorer Opera Safari (WebKit)
Basic support 1.0 (Yes) (Yes) (Yes) (Yes)
Feature Android Firefox Mobile (Gecko) IE Phone Opera Mobile Safari Mobile
Basic support (Yes) (Yes) (Yes) (Yes) (Yes)

See also

Метки документа и участники

 Внесли вклад в эту страницу: Sebastianz, yyss, kscarfone, joflynn, tregagnon, Sheppy, medicdude, teoli, ethertank, cers, hobophobe, osdm, jswisher, bradleymeck
 Обновлялась последний раз: Sebastianz,