<select> (Selection List)
This element defines a selection list within a form. Depending on the form of the selection list, the control allows the user to select one or more list options.
dir="ltr | rtl"
id="unique alphanumeric identifier"
name="unique alphanumeric name"
option and optgroup elements only
Attributes Defined by Internet Explorer
align="absbottom | absmiddle | baseline | bottom | left | middle | right | texttop | top" (4)
datafld="column name" (4)
datasrc="data source ID" (4)
hidefocus="true | false" (5.5)
unselectable="on | off" (5.5)
Standard Event Attributes
onblur, onchange, onclick, ondblclick, onkeydown, onkeypress, onkeyup, onmousedown, onmousemove, onmouseout, onmouseover, onmouseup
Events Defined by Internet Explorer
onactivate, onafterupdate, onbeforeactivate, onbeforecut, onbeforedeactivate, onbeforeeditfocus, onbeforepaste, onbeforeupdate, oncontextmenu, oncontrolselect, oncut, ondeactivate, ondragenter, ondragleave, ondragover, ondrop, onerrorupdate, onfocus, onfocusin, onfocusout, onhelp, onlosecapture, onmouseenter, onmouseleave, onmousewheel, onmove, onmoveend, onmovestart, onpaste, onpropertychange, onreadystatechange, onresize, onresizeend, onresizestart, onselectstart
Element Specific Attributes
- This Microsoft-specific attribute controls the alignment of the image with respect to the content on the page. The default value is left, but other values such as absbottom, absmiddle, baseline, bottom, middle, right, texttop, and top also might be supported. The meaning of these values should be similar to inserted objects such as images.
- This attribute is used to indicate the column name in the data source that is bound to the options in the <select> element.
- The value of this attribute is set to an identifier indicating the data source to pull data from.
- This attribute is used to turn off a form control. Elements will not be submitted nor can they receive any focus from the keyboard or mouse. Disabled form controls will not be part of the tabbing order. The browser also can gray out the form that is disabled in order to indicate to the user that the form control is inactive. This attribute requires no value.
- This attribute allows the selection of multiple items in the selection list. The default is single-item selection.
- This attribute allows a form control to be assigned a name so that it can be referenced by a scripting language. name is supported by older browsers such as Netscape 2 generation browsers, but the W3C encourages the use of the id attribute. For compatibility purposes both might have to be used.
- This attribute sets the number of visible items in the selection list. When the multiple attribute is not present, only one entry should show; however, when multiple is present, this attribute is useful to set the size of the scrolling list box.
- This attribute takes a numeric value indicating the position of the form control in the tabbing index for the form. Tabbing proceeds from the lowest positive tabindex value to the highest. Negative values for tabindex will leave the form control out of the tabbing order. When tabbing is not explicitly set, the browser might tab through items in the order they are encountered. Form controls that are disabled due to the presence of the disabled attribute will not be part of the tabbing index, although read-only controls will be.
Choose your favorite colors
<select multiple size="2">
HTML 2, 3.2, 4, 4.01, XHTML 1.0, 1.1, Basic
Internet Explorer 2, 3, 4, 5, 5.5, 6
Netscape 1, 2, 3, 4, 4.5-4.8, 6, 7
The HTML 4.01 specification reserves the attributes datafld and datasrc for future use, but these are removed under XHTML.
Internet Explorer's variant of the disabled attribute allows values of true and false, as well as the standard disabled value.
Under traditional HTML, the end tag </option> is often omitted.
Be careful of the name and id attribute problem that may occur, particularly when setting the multiple attribute. It may be better to have separate values.
The HTML 2.0 and 3.2 specifications define only multiple, name, and size attributes.