InterviewSolution
Saved Bookmarks
| 1. |
How do we create drop-down in HTML? |
|
Answer» We create drop-down in HTML using the <select> tag. The different values in the <select> tag are entered using a set of <option> tag. Each <option> tag have a value attribute and this only gets chosen when we select an option. A simple drop-down example is below. <!DOCTYPE html> <html> <head> <meta charset="utf-8" /> <title>DROPDOWN</title> <style> h1 { text-align: center; } form { DISPLAY: grid; place-content: center; grid-gap: 10px; BORDER: 1px solid black; } label { font-family: "Fira Sans", sans-serif; } </style> </head> <body> <h1>Drop-down Demo</h1> <form> <label for="profession-select">Choose Your Profession:</label> <select id="profession-select"> <option value="">--Please choose an option--</option> <option value="engineer">Engineer</option> <option value="doctor">Doctor</option> <option value="developer">Developer</option> <option value="architect">Architect</option> <option value="chef">Chef</option> <option value="manager">Manager</option> </select> </form> </body> </html> |
|