- Data Structure
- Networking
- RDBMS
- Operating System
- Java
- MS Excel
- iOS
- HTML
- CSS
- Android
- Python
- C Programming
- C++
- C#
- MongoDB
- MySQL
- Javascript
- PHP
- Physics
- Chemistry
- Biology
- Mathematics
- English
- Economics
- Psychology
- Social Studies
- Fashion Studies
- Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Create an option group in HTML
The HTML <optgroup> tag is used for grouping related options within your select list. This makes it easier for users to comprehend their choices when looking at a large list.
The following are the attributes −
Attribute | Value | Description |
---|---|---|
Disabled | Disabled | Disables the input control. The button won't accept changes from the user. It also cannot receive focus and will be skipped when tabbing. |
Label | Text | Defines a label to use when using <optgroup>. |
Example
You can try to run the following code to create an option group in HTML −
<!DOCTYPE html> <html> <head> <title>HTML optgroup Tag</title> </head> <body> <select> <optgroup label = "India"> <option value = "mumbai">Mumbai</option> <option value = "delhi">Delhi</option> </optgroup> <optgroup label = "USA"> <option value = "florida">Florida</option> <option value = "newyork">New York</option> </optgroup> </select> </body> </html>
Advertisements