HTML <select> tag

Updated: 10/11/2017 by Computer Hope

HTML select tagWhen writing in HTML, the <select> tag is an inline element used to designate a control that presents a drop-down menu of options. The options in the list are defined by the <option> tag and can be grouped together using <optgroup>. The following sections contain information about the <select> tag, including an example of it in use, as well as related attributes and browser compatibility.

Note: The <select> tag belongs to a group of tags called form elements.

Example code

<select>
<optgroup label="Mammals">
<option>Cat</option>
<option>Dog</option>
</optgroup>
<optgroup label="Birds">
<option>Crow</option>
<option>Eagle</option>
</optgroup>
<optgroup label="Dinosaurs">
<option>Raptor</option>
<option>Tyrannosaurus</option>
<option>Brachiosaurus</option>
</optgroup>
</select>

Example result

Choose your favorite animal from this list:


If you hover your mouse cursor over the right side of the box, a down arrow will appear. Click this arrow to choose your favorite animal.

Attributes

Within an HTML tag, an attribute dictates certain aspects of an HTML element. Attributes are made up of a name and value pair; all tags support standard attributes. The following table shows all of the current unique HTML attributes for the <select> tag, as well as a description of each.

Attribute Description
autofocus Designates that the drop-down list should automatically be focused upon the page loading
disabled Disables the drop-down list
form Designates the form(s) to which the <select> element belongs
multiple Designates that more than one option may be selected from the list
name Designates a name for the drop-down list
require Designates that the user is required to select a value before the form is submitted
size Specifies the number of visible options in a drop-down list

Compatibility

Internet Explorer Firefox Safari Opera Chrome
All versions All versions All versions All versions All versions

Additional form elements

Browser, Compatibility, Web design terms