HTML <option> Tag

Description

The <option> HTML element defines individual items in the list created using the <select> container. The width of the list is determined by the widest text specified in the <option> , and can also be changed using styles. If you plan to send list data to the server, you need to place the <select> element inside the form. This is also necessary when the list data is accessed through scripts.

Properties

Permitted Parents
A <select>, an <optgroup> or a <datalist> element
Content
Text
Start/End Tags
Start tag: optional, End tag: optional

Example

<select>
<option value ="new york">New York</option>
<option value ="london">London</option>
<option value ="sydney" selected>Sydney</option>
<option value ="auckland">Auckland</option>
</select>

Attributes

Attribute Definition
selected Specifies that this option will be pre-selected when the user first loads the page.
value Specifies the initial value of the option item.
label Specifies a label to be used as an alternative to the option item's contents. Useful if you'd prefer a shorter, more concise label.
disabled Disables the input control. The button won't accept changes from the user. It also cannot receive focus and will be skipped when tabbing.

Global Attributes

The <option> tag also supports the Global Attributes in HTML5

Event Attributes

The <option> tag also supports the Event Attributes in HTML5

Browser Support

Desktop
Explorer Edge Chrome Firefox Opera Safari
YesYes11YesYes
Tablets / Mobile
Android Chrome Firefox Opera Safari Samsung
YesYes4YesYesYes

Last updated by CSSPortal on: 6th December 2019