The <select>
represents a control that provides a menu of options:
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 starting and ending tag are mandatory. |
Permitted parents | any element that accepts phrasing content |
Permitted ARIA roles | menu |
DOM interface | HTMLSelectElement |
This element includes the global attributes.
autofocus
HTML5
autofocus
attribute, which is a Boolean.disabled
fieldset
; if there is no containing element with the disabled
attribute set, then the control is enabled.form
HTML5
multiple
name
required
HTML5
size
<!-- The second value will be selected initially --> <select name="text"> <!--Supplement an id here instead of using 'text'--> <option value="value1">Value 1</option> <option value="value2" selected>Value 2</option> <option value="value3">Value 3</option> </select>
The content of this element is static and not editable.
Specification | Status | Comments |
---|---|---|
HTML Living Standard The definition of '<select>' in that specification. | Living Standard | |
HTML5 The definition of '<select>' in that specification. | Recommendation | |
HTML 4.01 Specification The definition of '<select>' in that specification. | Recommendation |
Feature | Chrome | Edge | Firefox | Internet Explorer | Opera | Safari |
---|---|---|---|---|---|---|
Basic support | Yes2 | Yes | 13 | Yes | Yes | Yes2 |
autofocus |
Yes | Yes | 1 | Yes | Yes | Yes |
disabled |
Yes | Yes | 1 | Yes | Yes | Yes |
form |
Yes | Yes | 1 | Yes | Yes | Yes |
multiple |
Yes | Yes | 1 | Yes | Yes | Yes |
name |
Yes | Yes | 1 | Yes | Yes | Yes |
required |
Yes | Yes | 4 | 10 | Yes | Yes |
size |
Yes | Yes | 1 | Yes | Yes | Yes |
Feature | Android webview | Chrome for Android | Edge mobile | Firefox for Android | IE mobile | Opera Android | iOS Safari |
---|---|---|---|---|---|---|---|
Basic support | Yes1 2 | Yes2 | Yes | 44 | Yes | Yes | Yes2 |
autofocus |
Yes | Yes | Yes | 4 | Yes | Yes | Yes |
disabled |
Yes | Yes | Yes | 4 | Yes | Yes | Yes |
form |
Yes | Yes | Yes | 4 | Yes | Yes | Yes |
multiple |
Yes | Yes | Yes | 4 | Yes | Yes | Yes |
name |
Yes | Yes | Yes | 4 | Yes | Yes | Yes |
required |
Yes | Yes | Yes | 4 | No | Yes | Yes |
size |
Yes | Yes | Yes | 4 | Yes | 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. border-radius
on <select>
elements is ignored unless -webkit-appearance
is overridden to an appropriate value.
3. Historically, Firefox has allowed keyboard and mouse events to bubble up from the <option>
element to the parent <select>
element, although this behavior is inconsistent across many browsers. For better Web compatibility (and for technical reasons), when Firefox is in multi-process mode 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.
4. Firefox for Android, by default, sets a background-image
gradient on all <select multiple>
elements. This can be disabled using background-image: none
.
<form>
, <legend>
, <label>
, <button>
, <option>
, <datalist>
, <optgroup>
, <fieldset>
, <textarea>
, <keygen>
, <input>
, <output>
, <progress>
and <meter>
.<select>
: change, input.
© 2005–2018 Mozilla Developer Network and individual contributors.
Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.
https://developer.mozilla.org/en-US/docs/Web/HTML/Element/select