Avinash R
3
Q:

how to create a drop down list in html

<!-- Answer to: "html drop down list" -->

<label for="items">Choose an item:</label>

<!-- The value for `for=""` and `id=""` has to be same. -->

<select id="items">
  <option value="item-1">Item 1</option>
  <option value="item-2">Item 2</option>
  <option value="item-3">Item 3</option>
  <option value="item-4">Item 4</option>
</select>
28
<html>
 <head>
   <title>Selection Inputs</title>
 </head>
 <body>
   <form>
     <label for="selector"> <!-- Can add label if want -->
       <p>A "select" element allows users to input from a selection:</p>
       <select id="selector"> <!-- Use "select" to create object -->
         <option>Option 1</option> <!-- Add all applicable options -->
         <option>Option 2</option>
         <option selected>Option 3</option> <!-- add selected to change default from first option -->
         <optgroup label="Group"> <!-- To create nested options for categories use "optgroup" -->
           <option>Option 4</option>
           <option>Option 5</option>
       </select>
     </label>
   </form>
 </body>
</html>
5

<div class="dropdown">
  <button class="dropbtn">Dropdown</button>
  
<div class="dropdown-content">
    <a href="#">Link 
1</a>
    
<a href="#">Link 2</a>
    <a href="#">Link 3</a>
  </div>
</div> 
-1

New to Communities?

Join the community