jump

HTML 5: The Markup Language (ARIA Edition)

optionoption # T

The option element represents an option in a select control, or an option in a labelled set of options grouped together in an optgroup, or an option among the list of suggestions in a datalist.

Permitted contents #

Permitted attributes #

global attributes
Any attributes permitted globally.
disabled = d:string "disabled" or d:string "" #
Specifies that the element represents a disabled control.
selected = d:string "selected" or d:string "" #
Specifies that this option is pre-selected.
label = string #
Specifies a label for the option.
value = string #
Specifies a value for the option.

Additional constraints and admonitions #

Tag omission #

An option element must have a start tag.

An option element’s end tag may be omitted if the option element is immediately followed by another option element, or if it is immediately followed by an optgroup element, or if there is no more content in the parent element.

Permitted parent elements #

optgroup, select, datalist

DOM interface #

[NamedConstructor=Option(),
 NamedConstructor=Option(DOMString text),
 NamedConstructor=Option(DOMString text, DOMString value),
 NamedConstructor=Option(DOMString text, DOMString value, boolean defaultSelected),
 NamedConstructor=Option(DOMString text, DOMString value, boolean defaultSelected, boolean selected)]
interface HTMLOptionElement : HTMLElement {
           attribute boolean disabled;
  readonly attribute HTMLFormElement? form;
           attribute DOMString label;
           attribute boolean defaultSelected;
           attribute boolean selected;
           attribute DOMString value;

           attribute DOMString text;
  readonly attribute long index;
};