An Interest In:
Web News this Week
- April 1, 2024
- March 31, 2024
- March 30, 2024
- March 29, 2024
- March 28, 2024
- March 27, 2024
- March 26, 2024
May 27, 2021 07:02 am GMT
Original Link: https://dev.to/rajeshkumaryadavdotcom/html-group-related-options-in-a-drop-down-list-m54
HTML : Group related options in a drop-down list
To achieve the list as dropdown list shown below -
we can use optgroup
tag mentioned below-
<form action="/action_page.php"> <label for="skills">Choose a Skill:</label> <select name="skills" id="skills"> <optgroup label="FrontEnd"> <option value="Angular">Angular</option> <option value="React">React</option> </optgroup> <optgroup label="Backend"> <option value="Java">Java</option> <option value="PHP">PHP</option> </optgroup> </select> <br><br> <input type="submit" value="Submit"></form>
Demo
Conclusion
The <optgroup>
tag is used to group related options in a element (drop-down list).
If you have a long list of options, groups of related options are easier to handle for a user.
With all that being said, I highly recommend you keep learning!
Thank you for reading this article. Please feel free to connect with me on LinkedIn and Twitter.
Original Link: https://dev.to/rajeshkumaryadavdotcom/html-group-related-options-in-a-drop-down-list-m54
Share this article:
Tweet
View Full Article
Dev To
An online community for sharing and discovering great ideas, having debates, and making friendsMore About this Source Visit Dev To