C-Sharp | Java | Python | Swift | GO | WPF | Ruby | Scala | F# | JavaScript | SQL | PHP | Angular | HTML
HTML <optgroup> tagHTML <optgroup> tag is used to group related <options> in a drop down list within <select> element. Using <optgroup> tag with <select> makes easier to access the dropdown list especially if list has large number of options. Syntax<optgroup label=" ">........</optgroup> Following are some specifications about the HTML <optgroup> tag
Example<!DOCTYPE html> <html> <head> <title>Optgroup Tag</title> <style> body{ text-align: center; } select{ font-size:20px; font-weight:bold; color:green; } </style> </head> <body> <h2>Example of optgroup tag</h2> <label>Select your favourite brand</label><br> <select> <optgroup label="Laptop Maufacturur"> <option value="dell">Dell</option> <option value="hp">HP</option> <option value="lenovo">Lenovo</option> <option value="acer">Acer</option> </optgroup> <optgroup label="Mobile Manufacturer"> <option value="apple">Apple</option> <option value="nokia">Nokia</option> <option value="samsung">Samsung</option> <option value="coolpad">Coolpad</option> </optgroup> </select> </body> </html> Output: Attribute:Tag-specific attributes:
Global attribute:HTML <optgroup> tag supports the global attributes in HTML Event attribute:HTML <optgroup> tag supports the event attributes in HTML. Supporting Browsers
Next TopicHTML option Tag
|