HTML <select> tagS2C Home   « HTML <select> tag

Definition

The <select> tag is used to define a selectable drop-down list.

Example


<select>	
  <optgroup label="Normal">
    <option value="round">round</option>
    <option value="square">square</option>
  </optgroup>
  <optgroup label="Custom">
    <option value="hexagon">hexagon</option>
    <option value="star">star</option>
    <option value="triangle">triangle</option>
  </optgroup>
</select>

Required Attributes

NONE

Optional Attributes

multiple - varying usage dependant on operating system - not recommended. Using checkboxes may give a better user experience.

disabled - specifies the selectable drop-down list will be disabled until a certain condition occurs.


<select disabled="disabled"></select>

name - specifies a name for the selectable drop-down list.


<select name="name"></select>

size - specifies the viewable options in the selectable drop-down list.


<select size="3"></select>

Common Attributes

class - specifies a classname for the element allowing you to apply the style of the predefined class to the content.


<select class="classname"></select>

id - specifies a unique id for the element allowing you to apply the style of the predefined id to the content.


<select id="idname"></select>

style - specifies an inline style for the element allowing you to apply the style to the content.


<select style="color:red;text-align:left"></select>

tabindex - specifies the tab order of the element.


<select tabindex="1"></select>

title - specifies extra information about the content.


<select title="information about the content"></select>

Language Attributes

dir - specifies the directional flow of the content.


<!-- The text will flow from left to right -->
<select dir="ltr"></select>

<!-- The text will flow from right to left -->
<select dir="rtl"></select>

lang - specifies a language code for the content of the element.


<select lang="en"></select>

xml:lang - specifies a language code for the content of the element in XHTML documents.


<select xml:lang="fr"></select>

Document Event Attributes

NONE

Form Event Attributes

onblur - The JavaScript code to be run when an element loses focus.


<!-- Executes the go() function -->
<select onblur="go()"></select>

onchange - The JavaScript code to be run when an element gains focus.


<!-- Executes the go() function -->
<select onchange="go()"></select>

onfocus - The JavaScript code to be run when an element loses focus.


<!-- Executes the go() function -->
<select onfocus="go()"></select>

onselect - The JavaScript code to be run when an element gains focus.


<!-- Executes the go() function -->
<select onselect="go()"></select>

Image Event Attributes

NONE

Keyboard Event Attributes

onkeydown - The JavaScript code to be run when an element is in focus and keyboard key is pressed.


<!-- Executes the go() function -->
<select onkeydown="go()"></select>

onkeypress - The JavaScript code to be run when an element is in focus and keyboard key is pressed down and released.


<!-- Executes the go() function -->
<select onkeypress="go()"></select>

onkeyup - The JavaScript code to be run when an element is in focus and keyboard key is released.


<!-- Executes the go() function -->
<select onkeyup="go()"></select>

Mouse Event Attributes

onclick - The JavaScript code to be run when a mouse is clicked on the element.


<!-- Executes the go() function -->
<select onclick="go()"></select>

ondblclick - The JavaScript code to be run when a mouse is double clicked on the element.


<!-- Executes the go() function -->
<select ondblclick="go()"></select>

onmousedown - The JavaScript code to be run when the mouse button is pressed down while the cursor is over the element.


<!-- Executes the go() function -->
<select onmousedown="go()"></select>

onmousemove - The JavaScript code to be run when the mouse button is moved.


<!-- Executes the go() function -->
<select onmousemove="go()"></select>

onmouseout - The JavaScript code to be run when the mouse cursor moves off an element.


<!-- Executes the go() function -->
<select onmouseout="go()"></select>

onmouseover - The JavaScript code to be run when the mouse cursor moves over an element.


<!-- Executes the go() function -->
<select onmouseover="go()"></select>

onmouseup - The JavaScript code to be run when the mouse button is released while the cursor is over the element.


<!-- Executes the go() function -->
<select onmouseup="go()"></select>

go to home page Homepage go to top of page Top