HTML option - how to use <option> tag

The HTML <option> tag is used to define the list of items in a dropdown list. the dropdown list is rendered using the <select> tag. It can also define suggestions for input tags using the datalist tag.

Options can be grouped together using the optgroup tag.

Attributes

The option tag supports the global and event attributes.

disabled
Renders the option as disabled
label
Defines the name of the option
selected
Defines the default selected option
value
Defines the value of the option

Examples:

<select> <optgroup label="American cities"> <option value="New York">New York</option> <option value="Washington">Washington</option> </optgroup> <optgroup label="Chinese cities"> <option value="Beijing">Beijing</option> <option value="Shanghai">Shanghai</option> </optgroup> <optgroup label="Australian cities"> <option value="Sydney">Sydney</option> <option value="Melbourne">Melbourne</option> </optgroup> </select>

Related HTML tags and useful links: