The Role Of In HTML Forms (To Create Drop-Down Lists)

Disclosure: Your support helps keep the site running! We earn a referral fee for some of the services we recommend on this page. Learn more

Sharing is caring!

Element of
Building HTML Forms Is Easy: Tutorial With Copy-And-Paste Code
What does The Role Of In HTML Forms (To Create Drop-Down Lists) do?
The <select> element, used along with one or more <option> elements, creates a drop-down list of options for a web form. The <select> element creates the list and each <option> element is displayed as an available option in the list.
Display
inline

Code Example

<p><strong>Select your favorite species of flamingo.</strong></p>

<select>
          <option value="American">American flamingo</option>
          <option value="Andean">Andean flamingo</option>
          <option value="Chilean">Chilean flamingo</option>
          <option value="Greater">Greater flamingo</option>
          <option value="James's">James's flamingo</option>
          <option value="Lesser">Lesser flamingo</option>
</select>

Select your favorite species of flamingo.

Building Forms

The <select> element defines a list of selection items. Typically, this is used to display a menu. The items within the menu will be defined using <option>. Using its various attributes, you can allow users to select more than one item, or disable one or more options so that they cannot be selected. You can also disable the whole selection box, then use JavaScript to re-enable it when a certain form action is completed. To organize items in your menu, consider using <optgroup>.

Claire is seasoned technical writer, editor, and HTML enthusiast. She writes for HTML.com and runs a content agency, Red Robot Media.

Browser Support for select

AllAllAllAllAllAll