optgroup ... ⁄optgroup
HTML5 optgroup element
The optgroup element allows you to group the options from a list of options (within »video
element) under a common label.About optgroup
Display & support optgroup
- display in browser »video





Parents, children optgroup
- optgroup nested within elements »optgroup parents
- elements nested within optgroup »optgroup children
»examples
Attributes optgroup
- required: lable
- optional: disabled, global attributes, event attributes
Warning
The difference between Disabling an option and Disablig a group of options »video
Syntax optgroup
1 2 | <> ... </> <> ... » video |
Attributes and Values optgroup (comma separated)
< | attribute | = | "attribute_value(s)" | > | Video | Examples |
---|---|---|---|---|---|---|
1. specific attributes | ||||||
1. | disabled | = | "", , disabled | »video | <disabled> ... <⁄ > | |
2. | label | = | string (optgroup_name) | »video | <label="optgroup_name"> ...<⁄ > | |
All Specific Attributes | ||||||
2. global attributes | ||||||
1. | accesskey | = | keyboard key | »img | <accesskey="h"> ... </ > | |
2. | class | = | class name | »html »img | <class="class_name"> ... </ > | |
3. | contenteditable | = | "", , true, false | »html | <contenteditable="true"> ... </ > | |
4. | contextmenu | = | menu id value | »html | <contextmenu="menu_id_value"> ... </ > | |
5. | data-* | = | value | - | <data-http-error="404"> ... </ > | |
6. | dir | = | ltr, rtl, auto | »html | <dir="ltr"> ... </ > | |
7. | draggable | = | true, , false | »img | <draggable="false"> ... </ > | |
8. | dropzone | = | copy, move, link, string:, file: | - | <dropzone="copy"> ... </ > | |
9. | hidden | = | "", , hidden | »html »img | <hidden="hidden"> ... </ > | |
10. | id | = | id name | »html »img | <id="unique_id_name"> ... </ > | |
11. | itemid | = | URL | - | - | |
12. | itemprop | = | string | »link »a | - | |
13. | itemref | = | string | - | - | |
14. | itemscope | = | "", , itemscope | - | - | |
15. | itemtype | = | absolute URL | - | - | |
16. | lang | = | language code | »html »head»title »img | <lang="en"> ... </ > | |
17. | spellcheck | = | "", , true, false | »html | <spellcheck="true"> ... </ > | |
18. | style | = | CSS property:value | »html »img | <style="color:red"> ... </ > | |
19. | tabindex | = | integer | »img | <tabindex="3"> ... </ > | |
20. | title | = | text | »html »link»style »abbr»dfn »img »meter | <title="html page"> ... </ > | |
21. | translate | = | "", yes, no | »html »img | <translate="yes"> ... </ > | |
All Global Attributes | ||||||
3. global event attributes | ||||||
1. | onclick | = | script | » list | <element onclick="script" > ... | |
2. | ondblclick | = | script | » list | <element ondblclick="script" > ... | |
All Event Attributes |
Video demonstration optgroup element
HTML5 optgroup element: mark up a group of options
min | video details |
---|---|
00:00 | video tutorial: optgroup element |
00:05 | the optgroup element groups the options within select element under a common label |
00:14 | at this moment the options are not grouped, optgroup element is not present inside select element |
00:19 | these options can be grouped under a common label: GMT+ represents hours Est of Greenwich the common label can be: Est of Greenwich |
00:25 | while these options can be grouped under a common label: GMT- represents hours West of Greenwich the common label can be: West of Greenwich |
00:34 | adding the optgroup element in page + its required attribute: label attribute |
00:43 | adding the 2nd group |
00:51 | the 2 groups of options display; the options are now grouped under 2 groups: 1st group named: Est of Greenwich 2nd group named: West of Greenwich |