You are here: >

HTML <option> tag

HTML option tagWhen writing in HTML, the <option> tag is used to designate an item within the <optgroup>, <datalist>, or <select> elements. These options can be selected using a drop-down menu, or via autocomplete if the user starts typing one of them. The following sections contain information about the <option> tag, including an example of it in use, as well as related attributes and browser compatibility.

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

Example code

<div>Choose your favorite color from this list:</div>
<input list="colors" />
<datalist id="colors">
<option value="Red">
<option value="Green">
<option value="Blue">
<option value="Orange">
<option value="Purple">
</datalist>

Example result

Choose your favorite color 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 color.

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 <option> tag, as well as a description of each.

Attribute Description
disabled Disables the option
label Designates a short label for an option
selected Designates that the option should be selected as soon as the page loads
value Designates a value to best sent to the server then the option is selected

Compatibility

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

Additional form elements

Also see: Browser, Compatibility, Server