HTML » Tags » select

Version: 2.0, 3.2, 4.0

Compability: Explorer 4, 5  Netscape 4, 6

<select> ... </select>

The <select> tag is used to create a pull-down list form control (field). Control is a technical term that refers to the various elements (buttons, check boxes, radio buttons, text areas) that can be used inside a form to gather information.

The four tags that can be used to build a form are:
button     input     select     textarea
The select tag is used to delimit the start and stop of a multiple choice pull-down menu. The default for this tag is to create a one line window with a button on the left side. (Optionally, you can display a multi-line window.) When you single click onto the button with a mouse, the one line window expands to display a list of items. You can then select one item from the list by simply clicking on the item with the mouse. (Optionally, you can allow more than one item to be selected.) Note that the user can select or unselect the item(s) any number of times. When an item(s) is selected, it is added to the contents of the form and when the form is submitted, the selected item(s) will be passed along with all of the other contents.
The beauty of the select form control is that it can occupy as little as one line of space on a form, yet allow the user to choose from a very large selection of items. For example, your pull-down could be a list of all fifty states. As another example, note the pull-down list at the top of this HTML Quick Reference page. When you select an item, it acts as a link and directs you to another page in this HTML Quick Reference.
You must use the option or the optgroup tags to define each item in the menu.
The closing tag is mandatory.


<option selected>Angel fish</option>
<option>Cat fish</option>
<option>Neon tetra</option>

This is a simple pull-down that allows the choice of one item.

Language(s): HTML

See Also: