select tag (XHTML 1.0)

option selector


The select element allows the user to select between a pre-defined range of elements. It comes in two different forms: A dropdown list or a listbox. This behavior is controlled by the multiple attribute, as described below. Here's an example of the select element, rendered as a dropdown list:




Each element in the select box is generated by using an option tag, like this:


<select name="Persons"> 
     <option>Select person...</option> 
     <option>John Doe</option> 
     <option>Jane Doe</option> 

The multiple attribute

A standard select list only allows the selection of one option, but what if we wanted our user to be able to select more than one? That's exactly what the boolean multiple attribute is for. Here's an example:


<select name="Persons" multiple="multiple"> 
     <option>John Doe</option> 
     <option>Jane Doe</option> 

The result will look like this:



Select one item by clicking it, and more items by holding down the <Ctrl> or <Shift> key on your keyboard while clicking.



Attribute Deprecated Required Description
class  space-separated list of classes 
dir  direction for weak/neutral text 
disabled  unavailable in this context 
id  document-wide unique id 
lang  language code 
multiple  default is single selection 
name  field name 
size  rows visible 
style  associated style info 
tabindex  position in tabbing order 
title  advisory title 


Event Description
onblurthe element lost the focus 
onchangethe element value was changed 
onclicka pointer button was clicked 
ondblclicka pointer button was double clicked 
onfocusthe element got the focus 
onkeydowna key was pressed down 
onkeypressa key was pressed and released 
onkeyupa key was released 
onmousedowna pointer button was pressed down 
onmousemovea pointer was moved within 
onmouseouta pointer was moved away 
onmouseovera pointer was moved onto 
onmouseupa pointer button was released 2008 - 2017