HTML - <option>

In a Web form, the HTML <option> element is used to create a control representing an item within a <select>, an <optgroup> or a <datalist> HTML5 element.

Example

 

See <select> for examples.

Description  

In a Web form, the HTML <option> element is used to create a control representing an item within a <select>, an <optgroup> or a <datalist> HTML5 element.

Content categories None.
Permitted content Text with eventually escaped characters (like &eacute;).
Tag omission The start tag is mandatory. The end tag is optional if this element is immediately followed by another <option> element or an <optgroup>, or if the parent element has no more content.
Permitted parent elements A <select>, an <optgroup> or a <datalist> element.
DOM interface HTMLOptionElement

Browser Compatibility  

Feature Chrome Firefox (Gecko) Internet Explorer Opera Safari (WebKit)
Basic support 1.0 1.0 (1.7 or earlier)[1][2] (Yes) (Yes) (Yes)
Feature Android Firefox Mobile (Gecko) IE Phone Opera Mobile Safari Mobile
Basic support (Yes) 1.0 (1.0)[1] (Yes) (Yes) (Yes)

[1] Gecko doesn't display the value of the label attribute as option text if element's content is empty. See bug 1205213.

[2] Historically, Firefox has allowed keyboard and mouse events to bubble up from the <option> element to the parent <select> element. This doesn't happen in Chrome, however, although this behavior is inconsistent across many browsers. For better Web compatibility (and for technical reasons), when Firefox is in multi-process mode and the <select> element is displayed as a drop-down list. The behavior is unchanged if the <select> is presented inline and it has either the multiple attribute defined or a size attribute set to more than 1. Rather than watching <option> elements for events, you should watch for {event("change")}} events on <select>. See bug 1090602 for details.

See Also  

Specifications  

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

License

© 2016 Mozilla Contributors
Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.
https://developer.mozilla.org/en-us/docs/web/html/element/option

Element Forms HTML HTML forms Reference Web