jump

HTML: The Markup Language

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 = "disabled" or "" (empty string) or empty #
Specifies that the element represents a disabled control.
selected = "selected" or "" (empty string) or empty #
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(in DOMString text),
 NamedConstructor=Option(in DOMString text, in DOMString value),
 NamedConstructor=Option(in DOMString text, in DOMString value, in boolean defaultSelected),
 NamedConstructor=Option(in DOMString text, in DOMString value, in boolean defaultSelected, in 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;
};