HTML & CSS Course
HTML & CSS
/
Beginner

Select & Option

Definition

The `<select>` element is used to create a drop-down list. The `<option>` tags inside it define the available choices in the list.

Explain Like I'm New

It's a dropdown menu. You use `<select>` to build the outer box, and you put multiple `<option>` tags inside it to represent the choices the user can click on.

Real World Example

Selecting your Country or State during a checkout process.

Common Use Cases

  • •Conserving screen space when there are many choices
  • •Forcing a user to pick from a predetermined list

Interactive Example

Interview Questions

basic

  • Which tag acts as the container, and which acts as the choices?

intermediate

  • How do you make an option selected by default?

Flash Cards

Question

Container vs Choices?

Click to reveal answer
Answer

`<select>` is the container. `<option>` represents the individual choices.

Question

Selected by default?

Click to reveal answer
Answer

Add the `selected` attribute to the specific `<option>` tag you want to show first.