In this section, we are explaining about group of option in select box. Option group can be created by using of OPTGROUP element of HTML in select box. Optgroup keeps separated an one block to another block from each other. It is easier for user to understand quickly the categories of the list displayed in the select box.
OPTGROUP work with newer HTML version and it does not supported by older version of browser.
OPTGROUP used label to display group name in select box.
Demo
The example will explains the how to use optgroup in select box
<html> <head> <title>Select box option group</title> </head> <body> <select> <optgroup label="US State"> <option value="Alaska">Alaska</option> <option value="California">California</option> <option value="New Jersey">New Jersey</option> <option value="Washington">Washington</option> </optgroup> <optgroup label="India"> <option value="Punjab">Punjab</option> <option value="Kerala">Kerala</option> <option value="Rajasthan">Rajasthan</option> <option value="Maharashtra">Maharashtra</option> </optgroup> </select> </body> </html>




Link to Us