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

Sharing is caring!

Element of
How Do You Make Web Forms Using HTML? This Overview Explains Everything
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.

Code Example

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

          <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 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 and runs a content agency, Red Robot Media.

Browser Support for select