Bootstrap - Select Part 1: Introduction to Bootstrap 5 Select Dropdowns
What is a Select Dropdown?
A select dropdown is a form element that allows users to choose from a list of predefined options. It is commonly used for country selection, category selection, or any scenario requiring a limited set of choices.
Basic Syntax of a Bootstrap Select Dropdown
<div class="form-group">
<label for="basicSelect">Basic Select Dropdown</label>
<select class="form-select" id="basicSelect">
<option selected>Choose an option</option>
<option value="1">Option 1</option>
<option value="2">Option 2</option>
<option value="3">Option 3</option>
</select>
</div>
Explanation:
The <select> element is assigned the form-select class for Bootstrap styling.
<label> provides a title for better accessibility.
The <option selected> displays the default selection.
The user can choose from three options in the dropdown.