HTML » Tags » option

Version: 2.0, 3.2, 4.0

Compability: Explorer 4, 5  Netscape 4, 6

Syntax:
<option> ... </option>

The <option> tag is used to insert one item in a pull-down form control. You may repeat this tag an unlimited number of times in a pull-down list. (For example, you could list all fifty states.) By default, when an item is chosen, the value that is added to the contents of the form is the text that appears immediately after the opening option tag. However, you can specify a different value by using the value attribute.

This tag must be placed between the opening and closing select tags. The order of the option tags determines the default order of the list. However, you can use the selected attribute to specify one item always to appear at the top of the list.
 
In general, a pull-down list should be treated as a menu. It is recommended that the text for each item in the list be short, such as one or two words. A long text can be far too unwieldy to read and will probably annoy most users.
 
The ending tag is optional. However, it is recommended that it be included.
 

Examples

Code:
<select size="2">
<option selected>Angel fish</option>
<option>Cardinal tetra</option>
<option>Cat fish</option>
<option>Discus</option>
<option>Hatchet fish</option>
<option>Neon tetra</option>
</select>
Output:
Language(s): HTML

See Also: