Skip to: content, navigation

by Ian Lloyd

option (HTML element)

Spec
Depr. Empty Version
No No HTML 2
Browser support full matrix
IE5.5+ FF1+ Saf1.3+ Op9.2+
Full Full Full Full

Example

This code produces a simple select list in which the option elements are highlighted:

<form>
  <label for="favoritefood">Favorite food</label>
  <select name="favoritefood" id="favoritefood">
    <option>Cheese</option>
    <option>Egg</option>
    <option>Cabbage</option>
    ⋮
  </select>
</form>
Type
block-level element
Contains
text content only, no markup allowed
Contained by
select, optgroup

Description

Each option in a select element represents an option that the user can choose. The text contained between the opening <option> and closing </option> tags is displayed to the user, while the value attribute contains the actual data that will be sent when the form is submitted. The selected attribute is useful for preselecting a list option at page load.

Use This For …

The option element is used to create a single option in a select list. It would primarily be used for data capture purposes, but may also be used to create navigation. select lists are sometimes used for this purpose, with the destination presented as text content within the opening <option> and closing </option> tags, and the address, or URL, specified by the value attribute.

Compatibility

IE5.5Full
6.0Full
7.0Full
Firefox1.0Full
1.5Full
2.0Full
Safari1.3Full
2.0Full
3.0Full
Opera9.2Full
9.5Full

It causes no compatibility issues, and has excellent support across all tested browsers.

In this Section

Related Reading

User-contributed notes

There are no comments yet.

Add a note

To post a note on this topic, please log in with your SitePoint username and password. If you don't have an account yet, you can create a new account for free.

Related Products

The Principles of Beautiful Web Design

Best Seller!

You don’t need to go to Art School to design great looking web sites!

Book Cover: The Principles of Beautiful Web Design

Download the FREE sample chapters