W3 3.2y
4.0y
NS 3.0y
4.0y
IE 3.0y
4.0y
TV 1.2y
2.1y

<SELECT>...</SELECT>

Description

This element lets you create a listbox as an input field on a form. It is only valid inside the FORM element. The possible choices of the listbox are created with the OPTION element.

DTD

<!ELEMENT SELECT - - (OPTGROUP|OPTION)+ -- option selector -->
<!ATTLIST SELECT
  %attrs;                              -- %coreattrs, %i18n, %events --
  name        CDATA          #IMPLIED  -- field name --
  size        NUMBER         #IMPLIED  -- rows visible --
  multiple    (multiple)     #IMPLIED  -- default is single selection --
  disabled    (disabled)     #IMPLIED  -- unavailable in this context --
  tabindex    NUMBER         #IMPLIED  -- position in tabbing order --
  onfocus     %Script;       #IMPLIED  -- the element got the focus --
  onblur      %Script;       #IMPLIED  -- the element lost the focus --
  onchange    %Script;       #IMPLIED  -- the element value was changed --
  >
from the HTML 4.0 DTD, "Copyright © W3C, (MIT, INRIA, Keio). All Rights Reserved."

Attributes

Core attributes: class id style title
Internationalization attributes: dir lang
Events: onclick ondblclick onmousedown onmouseup onmouseover onmousemove onmouseout onkeypress onkeydown onkeyup

W3 3.2n
4.0n
NS 3.0n
4.0n
IE 3.0n
4.0n
TV 1.2y
2.1y
AUTOACTIVATE
Use the autoactivate attribute to activate the list automatically when the viewer selects it.

When the autoactivate attribute is not specified for a list, the viewer must press the GO button on the remote control (or Return on a keyboard) to activate the list and select an item from it. Also, when autoactivate is not specified, the arrow buttons on the remote control move the Highlight rectangle to the next selectable item on the web page.

When the autoactivate attribute is specified for a list or when the viewer has activated the list, the viewer can use the arrow buttons to move up and down within the list. The viewer can select an item by pressing the GO button.

You can use the autoactivate attribute with the multiple attribute or with the size attribute for sizes greater than 1.


W3 3.2n
4.0n
NS 3.0n
4.0n
IE 3.0n
4.0n
TV 1.2y
2.1y
BGCOLOR
Use the bgcolor attribute to set the background color for the list. The default value for bgcolor is #afafaf. You can use the bgcolor attribute with the multiple attribute or with the size attribute for sizes greater than 1.
See the page Using colors for a description on specifying colors.
W3 3.2n
4.0y
NS 3.0n
4.0n
IE 3.0n
4.0y
TV 1.2n
2.1n
DISABLED
This attribute makes the selection list non-functional, so the user cannot select an option from this list.
W3 3.2n
4.0n
NS 3.0n
4.0n
IE 3.0n
4.0n
TV 1.2y
2.1n
EXCLUSIVE
Use the exclusive attribute to prevent duplicate entries in the list.
W3 3.2y
4.0y
NS 3.0y
4.0y
IE 3.0y
4.0y
TV 1.2y
2.1y
MULTIPLE
Default only one item can be selected. This attribute makes it possible to let the user input multiple choices.
W3 3.2y
4.0y
NS 3.0y
4.0y
IE 3.0y
4.0y
TV 1.2y
2.1y
NAME
This attribute gives the input field a name which can be used by scripts.
W3 3.2n
4.0y
NS 3.0y
4.0y
IE 3.0n
4.0y
TV 1.2n
2.1y
ONBLUR
Specifies JavaScript code to execute when the field loses focus.
W3 3.2n
4.0y
NS 3.0y
4.0y
IE 3.0n
4.0y
TV 1.2n
2.1y
ONCHANGE
Specifies JavaScript code to execute when the value of the field is changed.
W3 3.2n
4.0y
NS 3.0y
4.0y
IE 3.0n
4.0y
TV 1.2n
2.1y
ONFOCUS
Specifies JavaScript code to execute when the field get the focus.
W3 3.2n
4.0n
NS 3.0n
4.0n
IE 3.0n
4.0n
TV 1.2y
2.1y
SELCOLOR
Use the selcolor attribute to set the background color for the selections in the list. The default value for selcolor is #eaeaea. You can use the selcolor attribute with the multiple attribute or with the size attribute for sizes greater than 1.
See the page Using colors for a description on specifying colors.
W3 3.2n
4.0n
NS 3.0n
4.0n
IE 3.0n
4.0n
TV 1.2y
2.1n
SHOWEMPTY
Use the showempty attribute to display empty lists with the empty string. You can use the showempty attribute with the multiple attribute or with the size attribute for sizes greater than 1.
W3 3.2y
4.0y
NS 3.0y
4.0y
IE 3.0y
4.0y
TV 1.2y
2.1y
SIZE
This sets the number of lines the field should be visible at one time.
W3 3.2n
4.0y
NS 3.0n
4.0n
IE 3.0n
4.0y
TV 1.2n
2.1n
TABINDEX
Description of the TABINDEX attribute
W3 3.2n
4.0n
NS 3.0n
4.0n
IE 3.0n
4.0n
TV 1.2y
2.1y
TEXT
Use the text attribute to set the color of the text for the items in the list. You can use the text attribute with the multiple attribute or with the size attribute for sizes greater than 1.
See the page Using colors for a description on specifying colors.
W3 3.2n NS 3.0n
4.0n
IE 3.0n
4.0n
TV 1.2y
2.1y
USESTYLE
Use the usestyle attribute so that the text in the list is rendered in the current style in effect for the page.

Examples

Source
<FORM>
What do you want on your pizza :
<SELECT multiple size="2">
<OPTION value="cheese">Cheese
<OPTION value="pepper">Peppers
<OPTION value="ansjovis">Ansjovis
<OPTION value="tomatoes">Tomatoes
</SELECT>
</FORM>
 
Result
What do you want on your pizza :
Statistics