-
Notifications
You must be signed in to change notification settings - Fork 317
Technique ARIA14: Replacing “invisible label” with “accessible name” #4482
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
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 e1df541
Replacing “invisible label” with “accessible name”
yatil b06d50d
Make it more XML compatible
yatil 5591aeb
Typos
yatil e8b2c18
Update techniques/aria/ARIA14.html
patrickhlauke f02a31f
Merge branch 'main' into fix-aria14
patrickhlauke b07f06f
Changed working example
yatil 4a3388b
Merge remote-tracking branch 'refs/remotes/yatil/fix-aria14'
yatil 3028a14
Re-add dialog stuff after the merge into my branch overwrote my changes
yatil f9ecb0e
Update techniques/aria/ARIA14.html
yatil 0c8ea5b
Merge branch 'main' into fix-aria14
patrickhlauke 1fb4415
Merge branch 'main' into fix-aria14
patrickhlauke 702b11f
Update techniques/aria/ARIA14.html
patrickhlauke 529c8d5
Update techniques/aria/ARIA14.html
patrickhlauke cd8a8e0
Merge branch 'main' into fix-aria14
patrickhlauke 56dcf6a
Merge branch 'main' into fix-aria14
patrickhlauke cbeb6cd
Merge branch 'main' into fix-aria14
kfranqueiro 3ed97e5
Merge branch 'main' into fix-aria14
patrickhlauke b69eee7
Update techniques/aria/ARIA14.html
patrickhlauke 6458f3d
typo
patrickhlauke cd3eaf4
Update techniques/aria/ARIA14.html
patrickhlauke bd1a073
Merge branch 'main' into fix-aria14
kfranqueiro 63729f9
Merge branch 'main' into fix-aria14
mbgower File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 “×” 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 “×” 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> | ||
patrickhlauke marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
patrickhlauke marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
||
<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"><label></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"><div></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"><input type="text"></code> or <code class="language-html"><textarea></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"><div id="box"> | ||
This is a pop-up box. | ||
<button aria-label="Close">X</button> | ||
</div></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> | ||
yatil marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
<p>On a page, a button displays a dialog (a <code class="language-html"><div></code> element) with additional information. The “close” element is implemented as a <code class="language-html"><button></code> containing merely the symbol “×”. 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"><dialog id="dialog"> | ||
This is the content of the dialog. | ||
<button aria-label="Close">×</button> | ||
</dialog></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"><div role="group" aria-labelledby="groupLabel"> | ||
<section class=" example"> | ||
<h3>A phone number with multiple fields</h3> | ||
|
||
<pre xml:space="preserve"><code class="language-html"><div role="group" aria-labelledby="groupLabel"> | ||
<span id="groupLabel">Work Phone</span> | ||
+<input autocomplete="tel-country-code" type="number" aria-label="country code"> | ||
<input autocomplete="tel-area-code" type="number" aria-label="area code"> | ||
<input autocomplete="tel-local" type="number" aria-label="subscriber number"> | ||
</div></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
51
working-examples/aria-label-accessible-name-dialog/index.html
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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();">×</button> | ||
</dialog> | ||
|
||
</body> | ||
|
||
</html> |
36 changes: 0 additions & 36 deletions
36
working-examples/aria-label-invisible-label-box/index.html
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.