Forms & Inputs

HTML <select> Tag

The <select> element is used to create a drop-down list.

Definition and Usage

The <select> element is used to create a drop-down list.

Standard Syntax:<select>...</select>

Interactive ExampleRunnable

HTML <select> Example

html
Try it Yourself
Live code demonstration for the <select> tag. Click "Try it Yourself" to edit and experiment in real time.
<div style="font-family: system-ui, sans-serif; padding: 16px; background: #ffffff; border-radius: 8px; border: 1px solid #e2e8f0; color: #0f172a;">
<label for="cars">Choose a car:</label>

<select 
    name="cars" id="cars">

       
      <option value="volvo">Volvo</option>

       
      <option value="saab">Saab</option>

       
      <option value="mercedes">Mercedes</option>

       
      <option value="audi">Audi</option>

      </select>
</div>

Attributes for <select>

7 Supported Attributes
AttributeValuesDefaultDescription
autofocusautofocusnoneSpecifies that the drop-down list should automatically get focus when the page loads
disableddisablednoneSpecifies that a drop-down list should be disabled
formform_idnoneDefines which form the drop-down list belongs to
multiplemultiplenoneSpecifies that multiple options can be selected at once
namenamenoneDefines a name for the drop-down list
requiredrequirednoneSpecifies that the user is required to select a value before submitting the form
sizenumbernoneDefines the number of visible options in a drop-down list
Global Attributes

The <select> tag also supports the standard global attributes in HTML, including class, id, style, title, hidden, and data-*.

HTML Global Attributes Reference →
Event Attributes

The <select> tag supports event attributes in HTML, such as onclick, onmouseover, onfocus, and more.

HTML Event Attributes Reference →

Browser Compatibility

ChromeEdgeFirefoxSafariOpera

More Tags in Forms & Inputs

View All 123Tags →