--- url: "https://www.w3.org/WAI/WCAG22/Techniques/html/H85" titulek: "H85: Using optgroup to group option elements inside a select | WAI | W3C" h1: "Technique H85:Using optgroup to group option elements inside a select" popis: "" jazyk: "en" kanonicka: "" drobecky: [] zdroj: "live" wayback_snapshot: "" stazeno: "2026-09-14 04:42:50" znaku: 4616 slov: 593 kodovani: "utf-8" sha256: "743f3bdafc8a75089d42b3b83c446d9060a6f6670625b2bef8d332e93ba46aaa" --- # Technique H85:Using `optgroup` to group `option` elements inside a `select` ## About this Technique This technique relates to [1.3.1 Info and Relationships](https://www.w3.org/WAI/WCAG22/Understanding/info-and-relationships) (**Sufficient** when used for making information and relationships conveyed through presentation programmatically determinable). This technique applies to HTML pages that collect user input. Techniques are examples of ways to meet Web Content Accessibility Guidelines (WCAG). They are **not required** to meet WCAG. Content can satisfy the normative requirements of WCAG even if it does not use any of the documented techniques. See [About WCAG Techniques](https://www.w3.org/WAI/WCAG22/Techniques/about). ## Description The objective of this technique is to group items in a selection list. A selection list is a set of allowed values for a form control such as a multi-select list or a combo box. Often, selection lists have groups of related options. Those groups should be semantically identified, rather than being delimited with "dummy" list entries, for example: an `option` element containing only a series of dashes to create a horizontal line. Semantically identifying groups of options helps to visually break up long lists so that users can more easily locate what they are interested in. In HTML, the `select` element is used to create both multi-select lists and combo boxes. The various allowed options are each indicated with `option` elements. To group options together, use the `optgroup` element, with the related `option` elements inside that element. Label the group with the `label` attribute so users will know what to expect inside the group. The `optgroup` element should be directly inside the `select` element, and the `option` elements directly inside the `optgroup`. It is possible for a `select` element to contain both single `option` elements and `optgroup` groups, though authors should consider if this is in fact the desired intent when using this. It is not possible to nest the `optgroup` element, so only one level of grouping can be done within a `select`. If grouping information is essential to understanding the list, authors may define `option` labels that can be understood even when the screen reader does not present the grouping information provided by `optgroup`. ## Examples ### Example 1 The following combo box collects data about favorite foods. Grouping by type allows users to select their preference more quickly. ```
``` ### Example 2 The following example shows how a multi-select box can make use of the `optgroup` element. ``` ``` ## Related Resources *No endorsement implied.* - [HTML - `select` element](https://html.spec.whatwg.org/multipage/form-elements.html#the-select-element) . - [HTML - `optgroup` element](https://html.spec.whatwg.org/multipage/form-elements.html#the-optgroup-element) . - [HTML - `option` element](https://html.spec.whatwg.org/multipage/form-elements.html#the-option-element) . - [WebAIM - Creating Accessible Forms](https://webaim.org/techniques/forms/) . ## Tests ### Procedure 1. Check the set of options within a selection list to see if there are groups of related options. 2. If there are groups of related options, they should be grouped with `optgroup` . ### Expected Results - Check #2 is true. Back to Top