Description

The <option> element represents an option in a dropdown list defined by the <select> element. A dropdown list must contain at least one <option> element.

The following table summarizes the usages context and the version history of this tag.

Parent:<select>, <optgroup>
Placement:Inline
Content:Text
Start/ End Tag:Start tag: required, End tag: optional
Version:HTML 2, 3.2. 4, 4.01, 5

Syntax

The basic syntax of the <option> tag is given with:

HTML/XHTML: <option value="optional-value"> ... </option>

Note: In HTML, the end tag for the <option> tag is not mandatory. In XHTML, the <option&t; tag must be properly closed i.e. both start tag and end tag are required.

The example below shows the <option> tag in action.

<select>
    <option value="ferrari">Ferrari</option>
    <option value="mercedes">Mercedes</option>
   <option value="porsche">Porsche</option>
</select>        

Tip: You can use the <optgroup> tag for grouping related options within a dropdown list. It will make your forms more accessible for the users, particularly when the user have to choose from a long list of options.

Tag-Specific Attributes

The following table shows the attributes that are specific to the <option> tag.

Global Attributes

Like all other HTML tags, the <option> tag supports the global attributes in HTML5.

Event Attributes

The <option> tag also supports the event attributes in HTML5.

Browser Compatibility

Element
<option>YesYesYesYesYes