<optgroup>
FormsGroups related options within a select dropdown, providing a label for the group.
Common Attributes
labeldisabledExample
<select>
<optgroup label="Fruits">
<option>Apple</option>
<option>Banana</option>
</optgroup>
</select>About the <optgroup> Element
The <optgroup> HTML element belongs to the Forms category of HTML elements. Groups related options within a select dropdown, providing a label for the group. Understanding when and how to use this element is essential for building well-structured, accessible, and SEO-friendly web pages.
The <optgroup> element requires both an opening <optgroup> and closing </optgroup> tag. Content placed between these tags becomes the element's children. This element is part of the current HTML Living Standard and is supported in all modern browsers including Chrome, Firefox, Safari, and Edge.
Proper use of semantic HTML elements like <optgroup> improves document structure, helps screen readers interpret content correctly, and provides signals to search engines about the purpose of different sections of your page. This leads to better accessibility scores, improved SEO rankings, and more maintainable code.