Skip to content

Commit f6f3643

Browse files
committed
Fix code sections
1 parent b283fc2 commit f6f3643

File tree

1 file changed

+17
-24
lines changed

1 file changed

+17
-24
lines changed

techniques/general/G211.html

Lines changed: 17 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ <h2>Examples</h2>
3333
<section class="example">
3434
<h3>Anchor text provides both the link's label and its accessible name</h3>
3535
<p id="linksample">Using conventional HTML, the text between the <code class="language-html">a</code> element's tags provides both the link's visible text and the accessible name "Code of conduct":</p>
36-
<code class="language-html">&lt;p&gt;Go to our &lt;a href="url-to-page-about-code.html"&gt;Code of conduct&lt;/a&gt;&lt;/p&gt;</code>
36+
<pre><code class="language-html">&lt;p&gt;Go to our &lt;a href="url-to-page-about-code.html"&gt;Code of conduct&lt;/a&gt;&lt;/p&gt;</code></pre>
3737
<section>
3838
<h4>Non-working sample of anchor</h4>
3939
<p>Go to our <a href="#linksample">Code of conduct</a></p>
@@ -44,19 +44,18 @@ <h4>Non-working sample of anchor</h4>
4444
<h3>Text in <code class="language-html">label</code> element provides name for input via <code class="language-html">for</code> attribute</h3>
4545
<p>The text between the <code class="language-html">label</code> tags also serves as the checkbox input's accessible name "Notify me of delays" by using the <code class="language-html">for</code> attribute which references the <code class="language-html">id</code> of the <code class="language-html">input</code>.</p>
4646
<pre><code class="language-html">&lt;input type="checkbox" id="notification" name="notify" value="delays"&gt;
47-
&lt;label for="notification"&gt;Notify me of delays&lt;/label&gt;
48-
</code></pre>
47+
&lt;label for="notification"&gt;Notify me of delays&lt;/label&gt;</code></pre>
4948
<section>
5049
<h4>Working sample of input</h4>
5150
<input type="checkbox" id="notification" name="notify" value="delays">
52-
<label for="notification">Notify me of delays</label>
51+
<label for="notification">Notify me of delays</label>
5352
</section>
5453
</section>
5554
<section class="example">
5655
<h3>The button text provides the accessible name</h3>
5756

5857
<p>The text inside a <code class="language-html">button</code> element becomes both its visible label and its accessible name:</p>
59-
<code class="language-html">&lt;button&gt;Send&lt;/button&gt;</code>
58+
<pre><code class="language-html">&lt;button&gt;Send&lt;/button&gt;</code></pre>
6059
<section>
6160
<h4>Non-working sample of button</h4>
6261
<button type="button">Send</button>
@@ -70,17 +69,15 @@ <h3>Simple Radio Button Group</h3>
7069
<img src="img/call-me-radio-button-group.png" alt="Call me when balance exceeds $10,000, Yes No">
7170
<figcaption>Figure 1 "Call me when balance exceeds $10,000 radio group, with Yes and No choices</figcaption>
7271
</figure>
73-
<p>The label for each component should be restricted to "Yes" and "No". To meet <a href="../../Understanding/info-and-relationships"> 1.3.1 Information and Relationships</a> and <a href="../../Understanding/labels-or-instructions.html"> 3.3.2 Labels or Instructions</a>, the "Call me…" text can be coded to convey the relationship to ATs, in this example by using a <code>fieldset</code> and <code>legend</code>.</p>
72+
<p>The label for each component should be restricted to "Yes" and "No". To meet <a href="../../Understanding/info-and-relationships"> 1.3.1 Information and Relationships</a> and <a href="../../Understanding/labels-or-instructions.html"> 3.3.2 Labels or Instructions</a>, the "Call me…" text can be coded to convey the relationship to ATs, in this example by using a <code class="language-html">fieldset</code> and <code class="language-html">legend</code>.</p>
7473
<p>If the label is not restricted to the string adjacent to the radio button, multiple interpretations of what constitutes the label can result in less uniform functionality. If "Yes" alone is not the label for the first radio button, is it "Call me when balance exceeds $10,000"? Or is it a combination of text strings, in which case is the order "Call me when balance exceeds $10,000 Yes" or "Yes, Call me when balance exceeds $10,000"? Decisions to combine text strings can have negative effects on screen reader users since the order of concatenation can affect meaning. In this example, "No, call me when balance exceeds $10,000" could be very confusing to a screen reader user.</p>
75-
<code>
76-
&lt;fieldset&gt;<br>
77-
&lt;legend&gt;Call me when balance exceeds $10,000?&lt;/legend&gt;&lt;br /&gt;<br>
78-
&lt;input type="radio" id="yes" name="callme" value="yes"&gt;<br>
79-
&lt;label for="yes"&gt;Yes&lt;/label&gt;<br>
80-
&lt;input type="radio" id="no" name="callme" value="no"&gt;<br>
81-
&lt;label for="no"&gt;No&lt;/label&gt;<br>
82-
&lt;/fieldset&gt;<br>
83-
</code>
74+
<pre><code class="language-html">&lt;fieldset&gt;<br>
75+
&lt;legend&gt;Call me when balance exceeds $10,000?&lt;/legend&gt;&lt;br /&gt;<br>
76+
&lt;input type="radio" id="yes" name="callme" value="yes"&gt;<br>
77+
&lt;label for="yes"&gt;Yes&lt;/label&gt;<br>
78+
&lt;input type="radio" id="no" name="callme" value="no"&gt;<br>
79+
&lt;label for="no"&gt;No&lt;/label&gt;<br>
80+
&lt;/fieldset&gt;</code></pre>
8481
<p class="working-example"><a href="../../working-examples/label-in-name-general/example1.html">Working example of Simple Radio Button Group</a></p>
8582
</section>
8683
<section class="example">
@@ -112,17 +109,15 @@ <h3>Stacked Labels</h3>
112109
<figcaption>Figure 4 New Password label positioned above input with a smaller-point text string about the password requirements positioned between the large label and the input.</figcaption>
113110
</figure>
114111
<p>The hint text in such implementations should be kept to a single line where possible, since accessibility issues can arise where a more lengthy hint separates the label from its input. Figure 4 illustrates that the concept of "adjacent text" is a guide for label interpretation, but cannot always serve as a hard rule.</p>
115-
<code>
116-
&lt;form&gt;<br>
112+
<pre>< class="language-html">&lt;form&gt;<br>
117113
&lt;label class="label" for="example-2"&gt;<br>
118114
Password<br>
119115
&lt;/label&gt;<br>
120116
&lt;span id="example-2-hint" class="hint"&gt;<br>
121117
Passwords must be 10 or more characters, and contain at least one capital, numeric and non-alphanumeric.<br>
122118
&lt;/span&gt;<br>
123119
&lt;input class="input" id="example-2" name="example-2" type="text" aria-describedby="example-2-hint"&gt;<br>
124-
&lt;/form&gt;<br>
125-
</code>
120+
&lt;/form&gt;</code></pre>
126121
<p class="working-example"><a href="../../working-examples/label-in-name-general/example2.html">Working example of stacked labels</a></p>
127122

128123
</section>
@@ -136,7 +131,7 @@ <h3>Range of inputs with few labels</h3>
136131
</figure>
137132

138133
<p>The two labels, "Hated it" and "Loved it", are adjacent to the first and last radio buttons, and should be their accessible names. Speech-input users can speak either of these labels to select a radio button, and then use arrow navigation (e.g., "Press right arrow") to modify the selection. "Rate your response" is the text describing the whole widget and can be associated as the group label (here using <code class="language-html">legend</code>). The three middle radio buttons do not have visible labels. In the code example they are given title attributes of "Disliked", "So-so" and "Liked" in order to meet 3.3.2 Labels or Instructions.</p>
139-
<pre><code class="language-html">&lt;fieldset&gt;
134+
<pre><code class="language-html">&lt;fieldset&gt;
140135
&lt;legend&gt;Rate your response&lt;/legend&gt;
141136
&lt;label for="hated"&gt;Hated it&lt;/label&gt;
142137
&lt;input type="radio" name="meal" id="hated" value="hated"&gt;
@@ -145,8 +140,7 @@ <h3>Range of inputs with few labels</h3>
145140
&lt;input type="radio" name="meal" id="okay" value="okay" title="Liked"&gt;
146141
&lt;input type="radio" name="meal" id="loved" value="loved"&gt;
147142
&lt;label for="loved"&gt;Loved it&lt;/label&gt;
148-
&lt;/fieldset&gt;
149-
</code></pre>
143+
&lt;/fieldset&gt;</code></pre>
150144
<p class="working-example"><a href="../../working-examples/label-in-name-general/example4.html">Working example of range of inputs</a></p>
151145
</section>
152146

@@ -158,8 +152,7 @@ <h3>Text in parentheses and punctuation</h3>
158152
<img src="img/inputs-simplified-accname.png" alt="Two text inputs: one with a label of 'Name' with an asterisk, one with a label of 'Birth date' and, in parentheses, YYYY-MM-DD">
159153
<figcaption>Figure 6 The "Name" and "Birth date" labels with additional information (and asterisk and an input formatting instruction, respectively)</figcaption>
160154
</figure>
161-
<pre><code class="language-html">
162-
&lt;label for="name"&gt;Name&lt;/label&gt; *
155+
<pre><code class="language-html">&lt;label for="name"&gt;Name&lt;/label&gt; *
163156
&lt;input type="text" name="name" id="name" required&gt;
164157
&lt;label for="birth"&gt;Birth date&lt;/label&gt; &lt;span id="mask"&gt;(YYYY-MM-DD)&lt;/span&gt;
165158
&lt;input type="text" name="birth" id="birth" aria-describedby="mask"&gt;</code></pre>

0 commit comments

Comments
 (0)