Skip to content
Merged
Show file tree
Hide file tree
Changes from 18 commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
05af16b
Formatting for easier editing
yatil Jul 3, 2025
e1df541
Replacing “invisible label” with “accessible name”
yatil Jul 3, 2025
b06d50d
Make it more XML compatible
yatil Jul 3, 2025
5591aeb
Typos
yatil Jul 3, 2025
e8b2c18
Update techniques/aria/ARIA14.html
patrickhlauke Jul 3, 2025
f02a31f
Merge branch 'main' into fix-aria14
patrickhlauke Jul 3, 2025
b07f06f
Changed working example
yatil Jul 4, 2025
4a3388b
Merge remote-tracking branch 'refs/remotes/yatil/fix-aria14'
yatil Jul 4, 2025
3028a14
Re-add dialog stuff after the merge into my branch overwrote my changes
yatil Jul 4, 2025
f9ecb0e
Update techniques/aria/ARIA14.html
yatil Jul 4, 2025
0c8ea5b
Merge branch 'main' into fix-aria14
patrickhlauke Jul 11, 2025
1fb4415
Merge branch 'main' into fix-aria14
patrickhlauke Jul 24, 2025
702b11f
Update techniques/aria/ARIA14.html
patrickhlauke Aug 8, 2025
529c8d5
Update techniques/aria/ARIA14.html
patrickhlauke Aug 8, 2025
cd8a8e0
Merge branch 'main' into fix-aria14
patrickhlauke Aug 8, 2025
56dcf6a
Merge branch 'main' into fix-aria14
patrickhlauke Aug 18, 2025
cbeb6cd
Merge branch 'main' into fix-aria14
kfranqueiro Sep 17, 2025
3ed97e5
Merge branch 'main' into fix-aria14
patrickhlauke Sep 22, 2025
b69eee7
Update techniques/aria/ARIA14.html
patrickhlauke Sep 22, 2025
6458f3d
typo
patrickhlauke Sep 22, 2025
cd3eaf4
Update techniques/aria/ARIA14.html
patrickhlauke Sep 22, 2025
bd1a073
Merge branch 'main' into fix-aria14
kfranqueiro Sep 30, 2025
63729f9
Merge branch 'main' into fix-aria14
mbgower Oct 1, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
133 changes: 83 additions & 50 deletions techniques/aria/ARIA14.html
Original file line number Diff line number Diff line change
@@ -1,63 +1,96 @@
<!DOCTYPE html><html lang="en"><head><title>Using aria-label to provide an invisible label where a visible label cannot be used</title><link rel="stylesheet" type="text/css" href="../../css/editors.css" class="remove"></head><body><h1>Using aria-label to provide an invisible label where a visible label cannot be used</h1><section class="meta"><p class="id">ID: ARIA14</p><p class="technology">Technology: aria</p><p class="type">Type: Technique</p></section><section id="applicability"><h2>When to Use</h2>
<!DOCTYPE html>
<html lang="en">
<head>
<title>Using aria-label to provide an accessible name where a visible label cannot be used</title>
<link rel="stylesheet" type="text/css" href="../../css/editors.css" class="remove">
</head>

<body>
<h1>Using aria-label to provide an accessible name where a visible label cannot be used</h1>
<section class="meta">
<p class="id">ID: ARIA14</p>
<p class="technology">Technology: aria</p>
<p class="type">Type: Technique</p>
</section>
<section id="applicability">
<h2>When to Use</h2>
<p>Technologies that support <a href="https://www.w3.org/TR/wai-aria/">Accessible Rich Internet Applications (WAI-ARIA)</a>. </p>
</section><section id="description"><h2>Description</h2>
<p>For sighted users, the context and visual appearance of an element can provide sufficient cues to determine the purpose. An example is the 'X' often used in the top right corner of pop-up <code class="language-html">div</code>s (light boxes) to indicate the control for closing the div.
</p>
<p>In some situations, elements can be given the attribute <code class="language-html">aria-label</code> to provide an accessible name for situations when there is no visible label due to a chosen design approach or layout but the context and visual appearance of the control make its purpose clear.</p>
</section>
<section id="description">
<h2>Description</h2>
<p>For sighted users, the context and visual appearance of an element can provide sufficient cues to determine the purpose. An example is the “&times;” often used in the top-right corner of dialogs to indicate the control for closing the dialog. While it might be visually clear that the “&times;” button closes the dialog, users with assistive technologies rely on accessible names that clearly communicate the purpose of components, in this case “Close”.
</p>
<p>When no clear visible text label is available due to design decisions, the accessible name can be set by using the <code class="language-html">aria-label</code> attribute instead, provided that the element has an implict or explicit <a href="https://www.w3.org/TR/wai-aria-1.2/#namefromauthor">role that supports naming</a>.</p>

Check warning on line 23 in techniques/aria/ARIA14.html

View workflow job for this annotation

GitHub Actions / spellcheck

Misspelled word (implict) Suggestions: (implicit*)

<p>The <code class="language-html">aria-label</code> attribute can also be used to provide an accessible name for custom controls that are not <a href="https://html.spec.whatwg.org/multipage/forms.html#category-label">labelable elements</a>, and cannot therefore use a <code class="language-html">&lt;label&gt;</code> element with the <code class="language-html">for</code> attribute.</p>

<p>In other situations, elements can be given the attribute <code class="language-html">aria-label</code> to provide an accessible name when the native HTML labeling element is not supported by the control - for example, when a <code class="language-html">div</code> set to <code class="language-html">contentEditable</code> is used instead of native form elements such as <code class="language-html">input type="text"</code> or <code class="language-html">textarea</code> in order to provide a richer text editing experience.</p>
<p>For instance, <code class="language-html">aria-label</code> or <code class="language-html">aria-labelledby</code> are the most suitable way to provide an accessible name when a <code class="language-html">&lt;div&gt;</code> element is made editable using the <code class="language-html">contentEditable</code> attribute, instead of native form elements such as <code class="language-html">&lt;input type="text"&gt;</code> or <code class="language-html">&lt;textarea&gt;</code> in order to provide a richer text editing experience.</p>

</section><section id="examples"><h2>Examples</h2>
</section>
<section id="examples">
<h2>Examples</h2>
<section class="example">
<h3>A close button in a pop-up box</h3>
<p>On a page, a link displays a pop-up box (a <code class="language-html">div</code>) with additional information. The 'close' element is implemented as a <code class="language-html">button</code> containing merely the letter 'X'. The property <code class="language-html">aria-label="close"</code> is used to provide an accessible name to the <code class="language-html">button</code>.</p>
<pre xml:space="preserve"><code class="language-html">&lt;div id="box"&gt;
This is a pop-up box.
&lt;button aria-label="Close"&gt;X&lt;/button&gt;
&lt;/div&gt;</code></pre>
<p class="working-example">Working example: <a href="../../working-examples/aria-label-invisible-label-box/">Close button example</a>.
</p>
<h3>A close button in a dialog</h3>

<p>On a page, a button displays a dialog (a <code class="language-html">&lt;div&gt;</code> element) with additional information. The close element is implemented as a <code class="language-html">&lt;button&gt;</code> containing merely the symbol “&times;”. The property <code class="language-html">aria-label="close"</code> is used to provide an accessible name to the button.</p>
<pre xml:space="preserve"><code class="language-html">&lt;dialog id=&quot;dialog&quot;&gt;
This is the content of the dialog.
&lt;button aria-label=&quot;Close&quot;&gt;&times;&lt;/button&gt;
&lt;/dialog&gt;</code></pre>
<p class="working-example">Working example: <a href="../../working-examples/aria-label-accessible-name-dialog/">Close button example</a>.
</p>

</section>
<section class="example">
<h3>A phone number with multiple fields</h3>
<pre xml:space="preserve"><code class="language-html">&lt;div role="group" aria-labelledby="groupLabel"&gt;
<section class=" example">
<h3>A phone number with multiple fields</h3>

<pre xml:space="preserve"><code class="language-html">&lt;div role="group" aria-labelledby="groupLabel"&gt;
&lt;span id="groupLabel"&gt;Work Phone&lt;/span&gt;
+&lt;input autocomplete="tel-country-code" type="number" aria-label="country code"&gt;
&lt;input autocomplete="tel-area-code" type="number" aria-label="area code"&gt;
&lt;input autocomplete="tel-local" type="number" aria-label="subscriber number"&gt;
&lt;/div&gt;</code></pre>

</section>
</section><section id="tests"><h2>Tests</h2>
<section class="procedure"><h3>Procedure</h3>
<p>For elements that use <code class="language-html">aria-label</code>:
</p>
<ol>
<li>Check that the value of the <code class="language-html">aria-label</code> attribute properly describes the purpose of an element where user input is required
</li>
</ol>
</section>
<section id="tests">
<h2>Tests</h2>
<section class="procedure">
<h3>Procedure</h3>
<p>For elements that use the <code class="language-html">aria-label</code> attribute:
</p>
<ol>
<li>Check that the value of the <code class="language-html">aria-label</code> attribute properly describes the purpose of an element where user input is required
</li>
</ol>
</section>
<section class="results"><h3>Expected Results</h3>
<ul>
<li>#1 is true.</li>
</ul>
<section class="results">
<h3>Expected Results</h3>
<ul>
<li>#1 is true.</li>
</ul>
</section>
</section><section id="related"><h2>Related Techniques</h2><ul>
<li><a href="../aria/ARIA6">ARIA6</a></li>
<li><a href="../aria/ARIA16">ARIA16</a></li>
</ul></section><section id="resources"><h2>Resources</h2>

<ul>
<li>
<a href="https://www.w3.org/WAI/ARIA/apg/">WAI-ARIA Authoring Practices Guide</a>
</li>
<li>
<a href="https://www.w3.org/TR/html-aam/">HTML Accessibility API Mappings</a>
</li>
</ul>

</section>
</body></html>
</section>
<section id="related">
<h2>Related Techniques</h2>
<ul>
<li><a href="../aria/ARIA6">ARIA6</a></li>
<li><a href="../aria/ARIA16">ARIA16</a></li>
</ul>
</section>
<section id="resources">
<h2>Resources</h2>

<ul>
<li>
<a href="https://www.w3.org/WAI/ARIA/apg/">WAI-ARIA Authoring Practices Guide</a>
</li>
<li>
<a href="https://www.w3.org/TR/html-aam/">HTML Accessibility API Mappings</a>
</li>
</ul>

</section>
</body>

</html>
51 changes: 51 additions & 0 deletions working-examples/aria-label-accessible-name-dialog/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
<!DOCTYPE html>
<html lang="en">

<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>aria-label Example: close button</title>

<style>
body {
font-family: sans-serif;
}

button {
border: 1px solid #000;
border-radius: 3px;
box-shadow: 3px 3px 4px rgba(0, 0, 0, .3);

&:hover,
&:focus-visible {
outline: 1px solid #000;
box-shadow: 6px 6px 4px rgba(0, 0, 0, .3);
}
}

dialog {
width: 30%;
height: 20%;
padding: 1rem;
border: 2px solid black;
background-color: #ddd;
}

dialog button {
float: right;
}
</style>

</head>

<body>

<p><button type="button" onclick="document.getElementById('dialog').showModal();">Display the dialog</button></p>

<dialog id="dialog">
This is the content of the dialog.
<button aria-label="Close" onclick="document.getElementById('dialog').close();">&times;</button>
</dialog>

</body>

</html>
36 changes: 0 additions & 36 deletions working-examples/aria-label-invisible-label-box/index.html

This file was deleted.

Loading