HTML <option> Tag

If this site has been useful, we’d love your support! Running this site takes time and resources, and every small contribution helps us keep creating valuable content. Consider buying us a coffee to keep things going strong!

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

The following table will show you the current browser support for the HTML <option> tag.

Desktop
Edge Chrome Firefox Opera Safari
1211154
Tablets / Mobile
Chrome Firefox Opera Safari Samsung Webview
184143.214.4

Last updated by CSSPortal on: 30th March 2024