Copyright © tutorialspoint.com

HTML <select> tag



Advertisements

Function:

The HTML <select> tag is used within a form for defining a select list.

Difference between HTML and XHTML:

NONE

Example:

<form action="/cgi-bin/dropdown.cgi" method="post">
<select name="dropdown">
<option value="Maths" selected>Maths</option>
<option value="Physics">Physics</option>
</select>
<input type="submit" value="Submit" />
</form>

This will produce following result:

Online Practice:

To Become more comfortable - Do Online Practice

Attributes:

AttributeValueDescription
disableddisabledDisables the input control. The button won't accept changes from the user. It also cannot receive focus and will be skipped when tabbing.
multiplemultipleWhen set, it specifies that multiple items can be selected at a time
namefiled nameAssigns a name to the input control.
sizenumberDefines the number of visible items in the drop-down list

Standard Attributes:

AttributeDescription
classDocument wide identifier
dirSpecifies the direction of the text
idDocument wide identifier
titleSpecifies a title to associate with the element.
styleHelps to include inline casecadubf style sheet.
langSets the language code.
xml:langSets the language code.
tabindexHelps determine the tabbing order
accesskeyAccess keys (or shortcut keys)

Event Attributes:

AttributeDescription
onfocusScript runs when control gets focus
onblurScript runs when control loses focus
onchangeScript runs when the element changes

Copyright © tutorialspoint.com