This wiki has been archived and is now read-only.


From HTML Wiki
Jump to: navigation, search


The <option> element represents an option in a select element or as part of a list of suggestions in a datalist element.

HTML Attributes

  • disabled = boolean
    if present, disable a option.

  • label = string
    Provides a label for element.
    If there isn't, the label of an option element is the textContent of the element.

  • value = string
    Provides a value for element.
    If there isn't, the value of an option element is the textContent of the element.

  • selected = boolean
    Represents the default selectedness of the element. [Example A]

See also global attributes.


Example A

[try it]:

<select name="city">
  <option value="Bos" selected>Boston</option>
  <option value="Cam">Cambridge</option>

Example B

As a child of an optgroup element [try it]:

<form action="courseselector.dll" method="get">
  <p>Which course would you like to watch today?
    <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 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 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>
  <p><input type=submit value="▶ Play">

HTML Reference

The HTML5 specification defines the <option> element in 4.10.12 The option element.