Dropdown menu

To create a dropdown menu, the select element (select) is used. Each item in the menu is an option element (option). The default selection will be the first option or, if the selected attribute (selected) is used, the option with the attribute. Notice that there is no value provided, just the term selected.

Using the multiple attribute (multiple) in the select element allows for more than one option to be selected (this may require pressing a key, such as the shift key, control key, or command key, while clicking multiple options). Again, the term multiple appears without a specified value.

The value option attribute behaves like the value input attributeAn attribute of an input element specifying information depending on the type of input, such as text for a button or a value used by JavaScript for a checkbox. for checkboxes and radio buttons, attaching a value to be used by JavaScript.

You may have noticed that unlike the checkboxes, the select element has no ID. There is no ID needed since there is no label element.

Note:

Hints:

  • undefined
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
1
2
<!DOCTYPE html>
<html lang="en">
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX