HTML <select> tag

The <select> tag is used to display a drop down list. The <select> tag only sets up a drop down list for usage, it does not create items within it. To create dropdown items, the <option> tag is used.

Attributes

Attribute Description Possible values
disabled Disables the drop down list (will be grayed out and inaccessible) disabled
multiple Specifies that more than one item at a time can be selected from the dropdown list multiple
name Sets the dropdown list's name dropdownName
size Sets how many items in the dropdown list can be seen at once (default is 1) dropdownSize

Standard attributes

class, dir, id, lang, style, tabindex, title, xml:lang

For more information on standard attributes, check out our HTML standard attributes reference page.

Event attributes

onblur, onchange, onclick, ondblclick, onfocus, onmousedown, onmouseup, onmouseover, onmousemove, onmouseout, onkeypress, onkeydown, onkeyup

For more information on event attributes, check out our HTML event attributes reference page.

Example

<label for="browser">Which is your favorite web browser?</label> <select name="browser"> <option value="FF">Firefox</option> <option value="Opera">Opera</option> <option value="Chrome">Chrome</option> <option value="Safari">Safari</option> <option value="IE">Internet Explorer</option> </select>
Output:

Tips & notes

Use the <label> tag to set the text of input elements in a form.

Use CSS to style form elements in many ways like setting a border, font size and color, background color, padding, and much more.

Use the <optgroup> tag to group together related elements in a dropdown list under one heading for better organization and usability.

Web Reference
  1. CSS reference
  2. RSS reference
  3. HTML reference


© Copyright 2011-2012 Landofcode.com
Terms of use | Privacy policy | Copyright information | Make a donation