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
The following table will show you the current browser support for the HTML <option>
tag.
Desktop | |||||
12 | 1 | 1 | 15 | 4 |
Tablets / Mobile | |||||
18 | 4 | 14 | 3.2 | 1 | 4.4 |
Last updated by CSSPortal on: 30th March 2024