|Contents||One or more optgroup or option elements|
|Contained in||Block-level elements, inline elements except button|
The select element defines a form control for the selection of options. While select is most useful within a form, XHTML 1.0 allows select in any block-level or inline element other than button. However, Netscape Navigator will not display any select elements outside of a form.
The select element contains one or more optgroup or option elements to provide a menu of choices for the user. Each choice is contained within an option element. Choices can be grouped logically through the optgroup element. select's name attribute provides the key sent to the server with the value of the selected option.
By default, the user can only select one option. The boolean multiple attribute allows the user to select multiple options, which are submitted as separate name/value pairs. The following example uses the multiple attribute to allow the selection of one or more options:
<p>Select one or more
sections to search:
<select name="sections" multiple="multiple">
<option>Web Authoring Reference</option>
The boolean disabled attribute, new in HTML 4.0 and poorly supported by current browsers, makes the select element unavailable. The user is unable to edit the disabled selection, no value is submitted with the form, the select element cannot receive focus, and the element is skipped when navigating the document by tabbing.
The tabindex attribute specifies a number between 0 and 32767 to indicate the tabbing order of the element. A select element with tabindex="0" or no tabindex attribute will be visited after any elements with a positive tabindex. Among positive tabindex values, the lower number receives focus first. In the case of a tie, the element appearing first in the HTML document takes precedence.
The size attribute of select hints that visual browsers should display the element as a list box with the specified number of options visible at any time. A scroll bar would allow access to any non-visible options. The size attribute is especially useful in select elements with numerous options and multiple selections allowed. In such a situation, some visual browsers will render the entire list in one large box without scrolling; a suitable size attribute helps such browsers give a more appropriate presentation.
The select element also takes a number of attributes to specify client-side scripting actions for various events. In addition to the core events common to most elements, select accepts the following event attributes: