YouTip LogoYouTip

Tag Optgroup

## HTML Tag ## Definition and Usage The tag is used to group related options in a select element. If you have a long list of options, it's easier to manage groups of related options. ## Browser Support | Element | Chrome | IE | Firefox | Safari | Opera | |---------|--------|-----|---------|--------|-------| | | Yes | Yes | Yes | Yes | Yes | ## Tips and Notes **Note:** The tag must be a direct child of the select element. The label attribute is required for the optgroup. **Tip:** Use this if you want to organize long lists. ## Differences Between HTML and XHTML In HTML, the tag is an empty element. In XHTML, the tag must be properly closed. ## Attributes | Attribute | Value | Description | |-----------|-------|-------------| | ( | disabled | Specifies that an option-group should be disabled | | ( | text | Specifies a label for an option-group | ## Standard Attributes The tag supports the following standard attributes: | Attribute | Value | Description | |-----------|-------|-------------| | ( | classname | Specifies a classname for an element | | ( | rtl ltr | Specifies the text direction for the content in an element | | ( | id | Specifies a unique id for an element | | ( | language_code | Specifies a language code for the content in an element | | ( | style_definition | Specifies an inline style for an element | | ( | text | Specifies extra information about an element | | [xml:lang]( | language_code | Specifies a language code for the content in an element (for XHTML documents) | ## Event Attributes The tag supports the following event attributes: | Attribute | Value | Description | |-----------|-------|-------------| | ( | script | Script to be run on a mouse click | | ( | script | Script to be run on a mouse double-click | | ( | script | Script to be run when mouse button is pressed | | ( | script | Script to be run when mouse button is released | | ( | script | Script to be run when mouse is moved over an element | | ( | script | Script to be run when mouse is moved | | ( | script | Script to be run when mouse is moved out of an element | | ( | script | Script to be run when a key is pressed | | ( | script | Script to be run when a key is pressed and released | | ( | script | Script to be run when a key is released | ## Example A select element with two option groups: ```html Volvo Saab Mercedes Audi ``` ## Related Pages HTML DOM reference: ( [โฎ Previous]( "HTML Tag")[Next โฏ]( "HTML Tag") ( Page](javascript:void(0)) --- ## Personalized Recommendation ( ( ( ( ( ( ( [Node.js Tutorial]( ( ( ( ( ( ( ( ( ( ## Social Platforms (javascript:void(0)) ( (javascript:void(0)) ยฉ 2013-2025 ( ( ( (
โ† Tag OptionTag Ol โ†’