The only content permitted inside this element is text with eventually escaped characters (like
é). The start tag is mandatory for this element. The end tag is optional if this element is immediately followed by another
<option> element or an
<optgroup>, or if the parent element has no more content. The parent of the
<option> tag can only be a
<optgroup> or a
Here is an example of using this tag:
<p>Which course would you like to watch today?</p> <p><label>Course: <select name="c"> <optgroup label="8.01 Physics I: Classical Mechanics"> <option value="8.01.1">Lecture 01: Powers of Ten</option> <option value="8.01.2">Lecture 02: 1D Kinematics</option> <option value="8.01.3">Lecture 03: Vectors</option> </optgroup> <optgroup label="8.02 Electricity and Magnestism"> <option value="8.02.1">Lecture 01: What holds our world together?</option> <option value="8.02.2">Lecture 02: Electric Field</option> <option value="8.02.3">Lecture 03: Electric Flux</option> </optgroup> <optgroup label="8.03 Physics III: Vibrations and Waves"> <option value="8.03.1">Lecture 01: Periodic Phenomenon</option> <option value="8.03.2">Lecture 02: Beats</option> <option value="8.03.3">Lecture 03: Forced Oscillations with Damping</option> </optgroup> </select> </label></p>
If this Boolean attribute is set, this option is not checkable. Often browsers grey out such control and it won’t receive any browsing event, like mouse clicks or focus-related ones. If this attribute is not set, the element can still be disabled if one its ancestors is a disabled
This attribute is text for the label indicating the meaning of the option. If the label attribute isn’t defined, its value is that of the element text content.
If present, this Boolean attribute indicates that the option is initially selected. If the
<option> element is the descendant of a
<select> element whose multiple attribute is not set, only one single
<option> of this
<select> element may have the selected attribute.
The content of this attribute represents the value to be submitted with the form, should this option be selected. If this attribute is omitted, the value is taken from the text content of the option element.
- Read more about the HTML
<option>element on MDN.
- You can also read the HTML
<option>tag reference on W3C.
2. As a registered user, you will also get to access features like choosing between a light and dark theme or anything else that we might implement in future.