HTML form optgroup tag
From w3cyberlearnings
Contents |
HTML - optgroup tag
optgroup tag uses to group related options in a drop down list.
HTML - Syntax optgroup Tag
<select name="NAME"> <optgroup label="option name"> <option value="apple">apple</option> <option value="banana">banana</option> </optgroup> </select
Example - Attributes
Attributes | Value | Example | Description |
---|---|---|---|
disabled | disabled | <optgroup label="something" disabled="disabled">Something</optgroup> | Disable a select option |
label | text | <optgroup label="fruit">...</optgroup> | Define a label for an option-group |
Example TRY-IT
<html> <head> <title>optgroup tag</title> </head> <body> <form name="form1" method="post" action=""> <select name="my_optgroup"> <optgroup label="fruit" disabled="disabled"> <option value="ap1">apple</option> <option value="ba1">banana</option> <option value="co1">coconut</option> </optgroup> <optgroup label="computer"> <option value="la1">Laptop</option> <option value="de1">Dell</option> <option value="to1">Toshiba</option> </optgroup> <optgroup label="role"> <option value="ma1">Manager</option> <option value="pr1">Programmer</option> <option value="te1">Tester</option> </optgroup> </select> </form> </body> </html>
Output
Related Link
- Form Input Password
- Form Input Textarea
- Form Select
- Form optgroup tag
- Form Label