Technique ARIA17:Using grouping roles to identify related form controls

Applicability

Technologies that support Accessible Rich Internet Applications (WAI-ARIA).

This technique relates to:

Description

The objective of this technique is to mark up a set of related controls within a form as a group. Any label associated with the group also serves as a common label or qualifier for individual controls in the group. Assistive technologies can indicate the start and end of the group and the group’s label as one navigates into and out of the group. This is a viable alternative for grouping form controls programmatically when the user interface’s design makes it difficult to employ the fieldset-legend technique (H71).

For a group of radio buttons, one could also use role="radiogroup" instead of role="group".

The group can be labeled using aria-labelledby.

This technique is not meant for wrapping all controls on a form within a single container with role="group".

Examples

Example 1: Social Security Number

Social security number fields which are 9 digits long and broken up into 3 segments can be grouped using role="group".

<div role="group" aria-labelledby="ssn1">
   <span id="ssn1">Social Security#</span> 
   <span style="color: #D90D0D;"> * </span>
   <input size="3" type="text" aria-required="true" title="First 3 digits" />-
   <input size="2" type="text" aria-required="true" title="Next 2 digits" />-
   <input size="4" type="text" aria-required="true" title="Last 4 digits" />
</div>

Working example: Multiple part field groups.

Example 2: Identifying radio groups

This example demonstrates use role=radiogroup. Note also that the radio buttons are custom controls with role=radio. (But the script to make the span actually work like radio buttons is not included in this example. ) One may optionally employ CSS to place a border around groups of such fields to visually reinforce the group relationship. The CSS properties are available below the form.

<h3>Set Alerts for your Account</h3>
  <div role="radiogroup" aria-labelledby="alert1">
    <p id="alert1">Send an alert when balance exceeds $ 3,000</p>
    <div>
      <span role="radio" aria-labelledby="a1r1" name="a1radio"></span>
      <span id="a1r1">Yes</span>
    </div>
    <div>
      <span role="radio" aria-labelledby="a1r2" name="a1radio"></span>
      <span id="a1r2">No</span>
    </div>
  </div>
  <div role="radiogroup" aria-labelledby="alert2">
    <p id="alert2">Send an alert when a charge exceeds $ 250</p>
    <div>
      <span role="radio" aria-labelledby="a2r1" name="a2radio"></span>
      <span id="a2r1">Yes</span>
    </div>
    <div>
      <span role="radio" aria-labelledby="a2r2" name="a2radio"></span>
      <span id="a2r2">No</span>
    </div>
  </div>
  <p><input type="submit" value="Continue" id="continue_btn" name="continue_btn" /></p>

Related CSS Style Definition to place a border around the group of fields :

div[role=radiogroup] {
  border: black thin solid;
} 

Working example: using grouping roles to identify related form controls.

Other sources

No endorsement implied.

Tests

Procedure

For groups of related controls where the individual labels for each control do not provide a sufficient description, and an additional group level description is needed:

  1. Check that the group of logically related input or select elements are contained within an element with role=group.
  2. Check that this group has an accessible name defined using aria-label or aria-labelledby.

Expected Results

  • #1 and #2 are true.