HTML Tags

HTML <select> Tag

Topic: HTML5 Tags ReferencePrev|Next

Description

The <select> element defines a selection list within a <form>. The selection list typically displayed in the browser as a pull-down menu (i.e. a drop-down list) from which a user can select one or more options depending on its attributes. Each option offered by the selection list is defined by an <option> element.

The following table summarizes the usages context and the version history of this tag.

Placement: Inline
Content: One or more of <optgroup> and/or <option>
Start/End Tag: Start tag: required, End tag: required
Version: HTML 2, 3.2, 4, 4.01, 5

Note: A <select> element must contain at least one <option> element. Options can be pre-selected for the user if attribute selected="selected" is specified to the start tag of the <option> element.


Syntax

The basic syntax of the <select> tag is given with:

HTML / XHTML: <select> ... </select>

The example below shows the <select> tag in action.

<select>
    <option value="ferrari">Ferrari</option>
    <option value="mercedes">Mercedes</option>
   <option value="porsche">Porsche</option>
</select>

Tag-Specific Attributes

The following table shows the attributes that are specific to the <select> tag.

Attribute Value Description
autofocus autofocus Specifies that the drop-down list should automatically get focus when the document is loaded.
disabled disabled This Boolean attribute indicates that drop-down list is disabled i.e. the drop-down list is not selectable.
form form-id Specifies the form that the select element is associated with i.e. its "form owner".
multiple multiple This Boolean attribute indicates that multiple options can be selected in the list.
name unique-name Defines the name for the select element.
required required This Boolean attribute indicates that an option with a non-empty value must be selected before form submission.
size number Specifies the number of options to show to the user.

Global Attributes

Like all other HTML tags, the <select> tag supports the global attributes in HTML5.


Event Attributes

The <select> tag also supports the event attributes in HTML5.


Browser Compatibility

The <select> tag is supported in all major modern browsers.

Browsers Icon

Basic Support—

  • Firefox 1+
  • Google Chrome 1+
  • Internet Explorer 2+
  • Apple Safari 1+
  • Opera 4+

Further Reading

See tutorial on: HTML Forms.

Other form-related tags: <form>, <fieldset>, <legend>, <label>, <input>, <textarea>, <optgroup>, <option>, <button>.

Bootstrap UI Design Templates Property Marvels - A Leading Real Estate Portal for Premium Properties