<select>



HTML <select> Tag


The <select> tag is used to create an drop down list box, that allows users to pick one among a number of given options.


Example :

<select>
  <option>HTML</option>
  <option>CSS</option>
  <option>JavaScript</option>
  <option>Python</option>
</select>

Output :


Example :

<select>
  <option>HTML</option>
  <option>CSS</option>
  <option disabled>JavaScript</option>
  <option selected>Python</option>
</select>

Output :


Attributes of <select> Tag


Attribute Value Description Example
autofocus - focus to this selectable drop-down list on page load.
<select name="name" autofocus>Selectable options</select>

 

disabled - Specifies that an option should be disabled.
<select name="name" disabled>Selectable options</select>

 

form form_id Specifies the form that the selectable drop-down list belongs to one or more forms.
<select name="name" form="formId">Selectable options</select>

 

multiple - Specifies that multiple options can be selected in the drop-down list.
<select name="name" multiple>Selectable options</select>

 

name text Specifies a name for the selectable drop-down list.
<select name="name">Selectable options</select>

 

required - Specifies the user must select an option before form submission.
<select name="name" required>Selectable options</select>

 

size number Specifies the number of visible options in a drop-down list.
<select name="name" size="3">Selectable options</select>