DEV Community

Cover image for HTML tags | optgroup
Carlos Espada
Carlos Espada

Posted on • Edited 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 role group.

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

Definition and example | Support

Top comments (1)

Collapse
 
eminaltan profile image
Emin Altan

I think this element contribute UX

👋 Kindness is contagious

Discover a treasure trove of wisdom within this insightful piece, highly respected in the nurturing DEV Community enviroment. Developers, whether novice or expert, are encouraged to participate and add to our shared knowledge basin.

A simple "thank you" can illuminate someone's day. Express your appreciation in the comments section!

On DEV, sharing ideas smoothens our journey and strengthens our community ties. Learn something useful? Offering a quick thanks to the author is deeply appreciated.

Okay