DEV Community πŸ‘©β€πŸ’»πŸ‘¨β€πŸ’»

DEV Community πŸ‘©β€πŸ’»πŸ‘¨β€πŸ’» is a community of 967,911 amazing developers

We're a place where coders share, stay up-to-date and grow their careers.

Create account Log in
Cover image for HTML tags | optgroup
Carlos Espada
Carlos Espada

Posted on • Updated on

HTML tags | optgroup

It is used to group related options in a <select>. In this way, the contents are easier for the user to handle in very long dropdown menus.

Cannot nest an <optgroup> within another <optgroup>.

It has two attributes: label to define the text that will be shown to the user as the title of the group of options, and disabled to disable the selection of all the options included in the group. The label attribute is required.

It has an implicit ARIA group role.

  • Type: block
  • Self-closing: No
  • Semantic value: No

Definition and example | Support

Top comments (0)

🌚 Life is too short to browse without dark mode