HTML - <select>

The HTML select (<select>) element represents a control that presents a menu of options. The options within the menu are represented by <option> elements, which can be grouped by <optgroup> elements. Options can be pre-selected for the user.

Examples

Example1

HTML
<!-- The second value will be selected initially -->
<select name="select">
  <option value="value1">Value 1</option> 
  <option value="value2" selected>Value 2</option>
  <option value="value3">Value 3</option>
</select>

Result

Notes

The content of this element is static and not editable.

Description  

The HTML select (<select>) element represents a control that presents a menu of options. The options within the menu are represented by <option> elements, which can be grouped by <optgroup> elements. Options can be pre-selected for the user.

Browser Compatibility  

Feature Chrome Firefox (Gecko) Internet Explorer Opera Safari
Basic support 1.0 1.0 (1.7 or earlier) [3] (Yes) (Yes) (Yes)
required attribute (Yes) 4.0 (2.0) 10 (Yes) (Yes)
Feature Android Firefox Mobile (Gecko) IE Mobile Opera Mobile Safari Mobile
Basic support (Yes) [1] 1.0 (1.0) [2] (Yes) (Yes) (Yes)
required attribute (Yes) 4.0 (2.0) No support (Yes) (Yes)

 

[1] In the Browser app for Android 4.1 (and possibly later versions), there is a bug where the menu indicator triangle on the side of a <select> will not be displayed if a background, border, or border-radius style is applied to the <select>.

[2] Firefox for Android, by default, sets a background-image gradient on all <select multiple> elements. This can be disabled using background-image: none.

[3] 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 change events on <select>. See bug 1090602 for details.

Chrome and Safari both ignore border-radius on <select> elements unless -webkit-appearance is overridden to an appropriate value.

See Also  

Specifications  

Specification Status Comments
HTML5
The definition of '<select>' in that specification.
Recommendation  
HTML 4.01 Specification
The definition of '<select>' in that specification.
Recommendation  

Usage content

Content categories flow content, phrasing content, interactive content, listed, labelable, resettable, and submittable form-associated element
Permitted content Zero or more <option> or <optgroup> elements.
Tag omission none, both the start tag and the end tag are mandatory
Permitted parent elements any element that accepts phrasing content

DOM Interface

This element implements the HTMLSelectElement interface.

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/select

Element Forms HTML HTML forms Reference Web