--- title: HTMLOptionElement slug: Web/API/HTMLOptionElement translation_of: Web/API/HTMLOptionElement ---
The HTMLOptionElement
interface represents {{HTMLElement("option")}} elements and inherits all classes and methods of the {{domxref("HTMLElement")}} interface.
{{InheritanceDiagram(600, 120)}}
Inherits properties from its parent, {{domxref("HTMLElement")}}.
form
of the corresponding {{HTMLElement("select")}} element, if the option is a descendant of a {{HTMLElement("select")}} element, or null if none is found.long
representing the position of the option within the list of options it belongs to, in tree-order. If the option is not part of a list of options, like when it is part of the {{HTMLElement("datalist")}} element, the value is 0
.Inherits methods from its parent, {{domxref("HTMLElement")}}.
HTMLOptionElement
object. It has four values: the text to display, text
, the value associated, value
, the value of defaultSelected
, and the value of selected
. The last three values are optional.Specification | Status | Comment |
---|---|---|
{{SpecName('HTML WHATWG', "#htmloptionelement", "HTMLOptionElement")}} | {{Spec2('HTML WHATWG')}} | |
{{SpecName('HTML5 W3C', "forms.html#the-option-element", "HTMLOptionElement")}} | {{Spec2('HTML5 W3C')}} | A constructor, Option() , has been added.The form property can be the null value. |
{{SpecName('DOM2 HTML', 'html.html#ID-70901257', 'HTMLOptionElement')}} | {{Spec2('DOM2 HTML')}} | The selected property changed its meaning: it now indicates if the option is currently selected and no longer if it was initally selected.The defaultSelected property is no longer read-only. |
{{SpecName('DOM1', 'level-one-html.html#ID-70901257', 'HTMLOptionElement')}} | {{Spec2('DOM1')}} | Initial definition |
{{Compat("api.HTMLOptionElement")}}