Forms & Controls

HTML <option> element

Build a form with the HTML form generator

Represents a choice in select or a suggestion in datalist. value supplies the submitted value for a selected option in a select. Use a distinct machine value when the displayed label may change. selected sets the default state rather than permanently locking the selection. In datalist, options are suggestions instead of selected choices. It accepts global HTML attributes; individual global features may be inapplicable or restricted.

Formal Syntax & Structure

html syntaxhtml
<option value="a">Choice A</option>

Parameters & Attributes

NameTypeDescription
disabledbooleanDisables supported controls or elements. Disabled form controls are generally not focusable, validated or submitted. The exact effect depends on the element; disabled="false" still disables.
labeltextSupplies a human-readable label for optgroup, option or track. It is not the same as the label element used to name form controls.
selectedbooleanSets an option's default selected state. The current selected property may change independently after interaction. A single-select should have only one default selected option.
valuestringSubmitted value; if omitted, derives from option text.

Return Value

HTMLOptionElement

Content model: Text in traditional select controls; customizable select has additional content rules.

Working Example

Example Snippethtml
<!doctype html><html lang="en">  <head>    <meta charset="utf-8">    <title>HTML example</title>  </head>  <body>    <label>      Format      <select name="format">        <option value="paper">Paperback</option>        <option value="digital">Digital</option>      </select>    </label>  </body></html>
HTML Reference