Course contentsShow
← Web Development
Lesson 100 of 2,9822. HTML FundamentalsFree lesson

The <select> and <option> Elements

Building dropdown menus with single and multiple selection modes using select and option tags.

The <select> and <option> Elements

What you'll learn: How to create dropdown menus that let users pick from a list of choices in your web forms.

What Are Select Dropdowns?

Think of a <select> element like a physical dropdown menu at a restaurant—when you click it, a list of options appears, and you choose one. The <select> tag creates the dropdown container, while each <option> tag inside represents one choice in that list.

Basic Structure

A dropdown menu requires both elements working together:

<label for="country">Choose your country:</label>
<select id="country" name="country">
  <option value="us">United States</option>
  <option value="ca">Canada</option>
  <option value="uk">United Kingdom</option>
</select>

The <select> wraps everything, and each <option> is one selectable item. The value attribute is what gets sent to the server when the form submits, while the text between the tags is what users see.

Pre-selecting an Option

You can mark one option as selected by default:

<option value="ca" selected>Canada</option>

Multiple Selection Mode

Sometimes users need to pick more than one choice. Add the multiple attribute:

<select name="interests" multiple>
  <option value="music">Music</option>
  <option value="sports">Sports</option>
  <option value="reading">Reading</option>
</select>

With multiple, users can hold Ctrl (or Cmd on Mac) to select several options at once. The dropdown changes appearance to show a scrollable list instead of a collapsed menu.

Key Takeaway: The <select> element creates dropdown menus containing <option> elements; use the multiple attribute to allow users to select more than one choice at a time.