Skip to content

Commit 81718bd

Browse files
fstrrpatrickhlaukembgower
authored
update ARIA 17 and supporting working examples (#2466)
closes #2465 1. update code examples to: 1. make the required field's label conform to 3.3.2 Labels Or Instructions. 2. remove invalid HTML. 3. add required `aria-checked` property for `role=radio` components. 2. mark up note as a note. 3. remove original author's publicly-visible name and employer from one working example. 4. change "#" to "number". 5. improve the `<title>` of "Multi-part fields like social security number and telephone number" example to remove text about reporting violations for forms, which the example isn't about. 6. make custom radio buttons round instead of square. 7. correct description of Resources links. 8. tweak the vertical alignment of some elements --------- Co-authored-by: Patrick H. Lauke <[email protected]> Co-authored-by: Mike Gower <[email protected]>
1 parent 4e7caee commit 81718bd

File tree

3 files changed

+148
-83
lines changed

3 files changed

+148
-83
lines changed

techniques/aria/ARIA17.html

Lines changed: 52 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,23 @@
1-
<!DOCTYPE html><html lang="en" xml:lang="en" xmlns="http://www.w3.org/1999/xhtml"><head><title>Using grouping roles to identify related form controls</title><link rel="stylesheet" type="text/css" href="../../css/editors.css" class="remove"/></head><body><h1>Using grouping roles to identify related form controls</h1><section class="meta"><p class="id">ID: ARIA17</p><p class="technology">Technology: aria</p><p class="type">Type: Technique</p></section><section id="applicability"><h2>When to Use</h2>
1+
<!DOCTYPE html>
2+
<html lang="en" xml:lang="en" xmlns="http://www.w3.org/1999/xhtml">
3+
<head>
4+
<title>Using grouping roles to identify related form controls</title>
5+
</head>
6+
<body>
7+
<h1>Using grouping roles to identify related form controls</h1>
8+
<section class="meta"><p class="id">ID: ARIA17</p><p class="technology">Technology: aria</p><p class="type">Type: Technique</p></section><section id="applicability"><h2>When to Use</h2>
29
<p>Technologies that support <a href="https://www.w3.org/TR/wai-aria/">Accessible Rich Internet Applications (WAI-ARIA)</a>. </p>
310
</section><section id="description"><h2>Description</h2>
411
<p>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 <code class="language-html">fieldset</code> / <code class="language-html">legend</code> technique (<a href="../html/H71">H71</a>).</p>
512
<p>For a group of radio buttons, one should use <code class="language-html">role="radiogroup"</code> instead of <code class="language-html">role="group"</code>.</p>
613
<p>The group can be labeled using <code class="language-html">aria-labelledby</code>.</p>
714
<p>This technique is not meant for wrapping all controls on a form within a single container with <code class="language-html">role="group"</code>.</p>
8-
</section><section id="examples"><h2>Examples</h2>
15+
</section>
16+
<section id="examples">
17+
<h2>Examples</h2>
918
<section class="example">
1019
<h3>Social Security Number</h3>
11-
12-
<p>Social security number fields which are nine digits long and broken up into three segments can be grouped using <code class="language-html">role="group"</code>.</p>
20+
<p>Social security number fields which are nine digits long and broken up into three segments can be grouped using <code class="language-html">role="group"</code>.</p>
1321
<pre xml:space="preserve"><code class="language-html">&lt;div role="group" aria-labelledby="ssn1"&gt;
1422
&lt;span id="ssn1"&gt;Social Security Number&lt;/span&gt;
1523
&lt;span style="color: #D90D0D;"&gt; (required)&lt;/span&gt;
@@ -23,60 +31,77 @@ <h3>Social Security Number</h3>
2331
<section class="example">
2432
<h3>Identifying radio groups</h3>
2533

26-
<p>This example demonstrates use <code class="language-html">role=radiogroup</code>. Note also that the radio buttons are custom controls with <code class="language-html">role=radio</code>. (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.</p>
34+
<p>This example demonstrates use <code class="language-html">role=radiogroup</code>. Note also that the radio buttons are custom controls with <code class="language-html">role=radio</code>. 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.</p>
2735
<pre xml:space="preserve"><code class="language-html">&lt;h3&gt;Set Alerts for your Account&lt;/h3&gt;
2836
&lt;div role="radiogroup" aria-labelledby="alert1"&gt;
29-
&lt;p id="alert1"&gt;Send an alert when balance exceeds $ 3,000&lt;/p&gt;
37+
&lt;p id="alert1"&gt;Send an alert when balance exceeds $3,000&lt;/p&gt;
3038
&lt;div&gt;
31-
&lt;span role="radio" aria-labelledby="a1r1" name="a1radio"&gt;&lt;/span&gt;
39+
&lt;span role="radio" aria-checked="false" aria-labelledby="a1r1" name="a1radio"&gt;&lt;/span&gt;
3240
&lt;span id="a1r1"&gt;Yes&lt;/span&gt;
3341
&lt;/div&gt;
3442
&lt;div&gt;
35-
&lt;span role="radio" aria-labelledby="a1r2" name="a1radio"&gt;&lt;/span&gt;
43+
&lt;span role="radio" aria-checked="false" aria-labelledby="a1r2" name="a1radio"&gt;&lt;/span&gt;
3644
&lt;span id="a1r2"&gt;No&lt;/span&gt;
3745
&lt;/div&gt;
3846
&lt;/div&gt;
39-
&lt;div role="radiogroup" aria-labelledby="alert2"&gt;
40-
&lt;p id="alert2"&gt;Send an alert when a charge exceeds $ 250&lt;/p&gt;
47+
&lt;div role="radiogroup" aria-checked="false" aria-labelledby="alert2"&gt;
48+
&lt;p id="alert2"&gt;Send an alert when a charge exceeds $250&lt;/p&gt;
4149
&lt;div&gt;
42-
&lt;span role="radio" aria-labelledby="a2r1" name="a2radio"&gt;&lt;/span&gt;
50+
&lt;span role="radio" aria-checked="false" aria-labelledby="a2r1" name="a2radio"&gt;&lt;/span&gt;
4351
&lt;span id="a2r1"&gt;Yes&lt;/span&gt;
4452
&lt;/div&gt;
4553
&lt;div&gt;
46-
&lt;span role="radio" aria-labelledby="a2r2" name="a2radio"&gt;&lt;/span&gt;
54+
&lt;span role="radio" aria-checked="false" aria-labelledby="a2r2" name="a2radio"&gt;&lt;/span&gt;
4755
&lt;span id="a2r2"&gt;No&lt;/span&gt;
4856
&lt;/div&gt;
4957
&lt;/div&gt;
50-
&lt;p&gt;&lt;input type="submit" value="Continue" id="continue_btn" name="continue_btn"&gt;&lt;/p&gt;</code></pre>
58+
&lt;input type="submit" value="Continue" name="continue_btn"&gt;</code></pre>
5159

5260
<p>Related CSS Style Definition to place a border around the group of fields:</p>
5361
<pre xml:space="preserve"><code class="language-css">div[role=radiogroup] {
5462
border: black thin solid;
5563
}</code></pre>
5664
<p class="working-example">Working example: <a href="../../working-examples/aria-grouping-related-fields/">using grouping roles to identify related form controls</a>.</p>
65+
66+
<div class="note">
67+
The script to make the <code class="language-html">span</code> actually work like radio buttons is not included in this example. For a similar, but coded slightly differently, working example, see the the ARIA Authoring Practices' <a href="https://www.w3.org/WAI/ARIA/apg/patterns/radio/examples/radio-activedescendant/">Radio Group Example Using aria-activedescendant</a> example.
68+
</div>
5769

5870
</section>
59-
</section><section id="tests"><h2>Tests</h2>
60-
<section class="procedure"><h3>Procedure</h3>
71+
</section>
72+
<section id="tests">
73+
<h2>Tests</h2>
74+
<section class="procedure">
75+
<h3>Procedure</h3>
6176
<p>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:</p>
6277
<ol>
63-
<li> Check that the group of logically related input or select elements are contained within an element with <code class="language-html">role=group</code>.</li>
78+
<li> Check that the group of logically related input or select elements are contained within an element with <code class="language-html">role=group</code>, or <code class="language-html">role=radiogroup</code> depending on the type of elements the group contains.</li>
6479
<li> Check that this group has an accessible name defined using <code class="language-html">aria-label</code> or <code class="language-html">aria-labelledby</code>.</li>
6580
</ol>
6681
</section>
67-
<section class="results"><h3>Expected Results</h3>
82+
<section class="results">
83+
<h3>Expected Results</h3>
6884
<ul>
6985
<li>#1 and #2 are true.</li>
7086
</ul>
7187
</section>
72-
</section><section id="related"><h2>Related Techniques</h2><ul>
73-
<li><a href="../html/H71">H71</a></li>
74-
</ul></section><section id="resources"><h2>Resources</h2>
75-
76-
<ul>
77-
<li>
78-
<a href="https://www.w3.org/TR/wai-aria/#group">Accessible Rich Internet Applications (WAI-ARIA), The Roles Model</a>
79-
</li>
80-
</ul>
88+
</section>
89+
<section id="related">
90+
<h2>Related Techniques</h2>
91+
<ul>
92+
<li><a href="../html/H71">H71</a></li>
93+
</ul>
94+
</section>
95+
<section id="resources">
96+
<h2>Resources</h2>
97+
<ul>
98+
<li>
99+
<a href="https://www.w3.org/TR/wai-aria/#group">ARIA <code class="language-html">group</code> role</a>
100+
</li>
101+
<li>
102+
<a href="https://www.w3.org/TR/wai-aria/#radiogroup">ARIA <code class="language-html">radiogroup</code> role</a>
103+
</li>
104+
</ul>
81105
</section>
82-
</body></html>
106+
</body>
107+
</html>
Lines changed: 35 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,45 @@
11
<!DOCTYPE html>
22
<html lang="en">
33
<head>
4-
<meta charset="utf-8">
5-
<title>Marking up forms and reporting violations for forms</title>
4+
<meta charset="utf-8">
5+
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
6+
<title>Marking up multi-part groups of form fields</title>
7+
<style>
8+
:root {
9+
box-sizing: border-box;
10+
}
11+
12+
body{
13+
font:100% / 1.5 system-ui;
14+
}
15+
16+
#ssn1{
17+
margin-block-end: 0.5rem;
18+
}
19+
20+
div > *{
21+
vertical-align: middle;
22+
}
23+
24+
input{
25+
border:1px solid #000;
26+
font:inherit;
27+
}
28+
29+
:focus-visible{
30+
outline: 2px solid blue;
31+
outline-offset: 2px;
32+
}
33+
</style>
634
</head>
735
<body>
836

9-
<h2>Multi-part fields like social security number and telephone#:</h2>
10-
<form action="#" method="post">
37+
<h2>Multi-part fields like social security number and telephone number</h2>
1138
<div role="group" aria-labelledby="ssn1">
12-
<span id="ssn1">Social Security Number</span>
13-
<span style="color:#D90D0D;"> (required) </span>
14-
<input size="3" type="text" aria-required="true" title="First 3 digits">-
15-
<input size="2" type="text" aria-required="true" title="Next 2 digits">-
16-
<input size="4" type="text" aria-required="true" title="Last 4 digits">
39+
<div id="ssn1">Social Security Number (required)</div>
40+
<input size="3" type="text" aria-required="true" title="First 3 digits" /> -
41+
<input size="2" type="text" aria-required="true" title="Next 2 digits" /> -
42+
<input size="4" type="text" aria-required="true" title="Last 4 digits" />
1743
</div>
18-
</form>
1944
</body>
2045
</html>

working-examples/aria-grouping-related-fields/index.html

Lines changed: 61 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -1,77 +1,92 @@
11
<!DOCTYPE html>
2-
3-
4-
<html lang="en" xmlns="http://www.w3.org/1999/xhtml">
2+
<html lang="en">
53
<head>
6-
<meta charset="utf-8"/>
7-
<title>Example - Using grouping roles to identify related form controls</title>
8-
<style>
9-
10-
div[role=group], div[role=radiogroup] {
11-
border: black thin solid;
12-
}
13-
14-
span[role=radio] {
15-
border: 1px black solid;
16-
width: 0.8em;
17-
height: 0.8em;
18-
display: inline-block;
19-
}
20-
21-
div[role=radiogroup] div {
22-
display: inline-block;
23-
padding: 4px 4px 0 15px;
24-
}
4+
<meta charset="utf-8">
5+
<title>Using grouping roles to identify related form controls</title>
6+
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
7+
<style>
8+
9+
:root{
10+
box-sizing: border-box;
11+
}
12+
13+
body{
14+
font:100% / 1.5 system-ui;
15+
}
16+
17+
div[role=group], div[role=radiogroup] {
18+
border: 1px hsl(0,0%,60%) solid;
19+
margin-block-end: 1rem;
20+
padding:1rem;
21+
}
22+
23+
div[role=group] p, div[role=radiogroup] p{
24+
font-weight: 600;
25+
margin-block: 0;
26+
}
27+
28+
div[role=group] span, div[role=radiogroup] span{
29+
vertical-align: middle;
30+
}
31+
32+
span[role=radio] {
33+
border: 1px black solid;
34+
border-radius:50%;
35+
width: 0.8em;
36+
height: 0.8em;
37+
display: inline-block;
38+
&:focus-visible{
39+
outline: 2px solid blue;
40+
outline-offset: 2px;
41+
}
42+
}
43+
44+
div[role=radiogroup] div {
45+
display: inline-block;
46+
padding: 4px 4px 0 15px;
47+
}
48+
49+
#continue_btn{
50+
display:block;
51+
font:inherit;
52+
}
2553

2654
</style>
2755
</head>
2856

29-
30-
3157
<body>
3258

3359
<h1>Example of using grouping roles to identify related form controls</h1>
3460

35-
<p>NB: This example does not use the script needed to make it work, but does include enough to understand the grouping mechanism.</p>
36-
<hr/>
61+
<div class="note" role="note">
62+
<p>This example does not use scripts needed to make the form work, including having a roving <code>tabindex</code>, and checking and un-checking the custom radio buttons.</p>
63+
</div>
3764

38-
<h3>Set Alerts for your Account</h3>
39-
40-
41-
<form action="#" method="post" id="alerts1">
42-
<div role="group" aria-labelledby="accountnum">
43-
<span id="accountnum">Your 12-digit account number</span>
44-
<p>
45-
<input size="4" type="text" title="First 4 digits" name="part1"/> -
46-
<input size="4" type="text" title="Next 4 digits" name="part2"/> -
47-
<input size="4" type="text" title="Last 4 digits" name="part3"/>
48-
</p>
49-
</div>
65+
<h3>Set Alerts For Your Account</h3>
5066

5167
<div role="radiogroup" aria-labelledby="alert1">
52-
<p id="alert1">Send an alert when balance exceeds $ 3,000</p>
68+
<p id="alert1">Send an alert when balance exceeds $3,000</p>
5369
<div>
54-
<span role="radio" aria-labelledby="a1r1" name="a1radio" tabindex="0"></span>
70+
<span role="radio" aria-checked="false" aria-labelledby="a1r1" tabindex="0"></span>
5571
<span id="a1r1">Yes</span>
5672
</div>
5773
<div>
58-
<span role="radio" aria-labelledby="a1r2" name="a1radio" tabindex="-1"></span>
74+
<span role="radio" aria-checked="false" aria-labelledby="a1r2" tabindex="-1"></span>
5975
<span id="a1r2">No</span>
6076
</div>
6177
</div>
6278
<div role="radiogroup" aria-labelledby="alert2">
63-
<p id="alert2">Send an alert when a charge exceeds $ 250</p>
79+
<p id="alert2">Send an alert when a charge exceeds $250</p>
6480
<div>
65-
<span role="radio" aria-labelledby="a2r1" name="a2radio" tabindex="0"></span>
81+
<span role="radio" aria-checked="false" aria-labelledby="a2r1" tabindex="0"></span>
6682
<span id="a2r1">Yes</span>
6783
</div>
6884
<div>
69-
<span role="radio" aria-labelledby="a2r2" name="a2radio" tabindex="-1"></span>
85+
<span role="radio" aria-checked="false" aria-labelledby="a2r2" tabindex="-1"></span>
7086
<span id="a2r2">No</span>
7187
</div>
7288
</div>
73-
<p><input type="submit" value="Continue" id="continue_btn" name="continue_btn"/></p>
74-
</form>
89+
<input type="submit" value="Continue" name="continue_btn">
7590

7691
</body>
7792
</html>

0 commit comments

Comments
 (0)