-
Notifications
You must be signed in to change notification settings - Fork 301
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
Open
yatil
wants to merge
12
commits into
w3c:main
Choose a base branch
from
yatil:fix-aria14
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 5 commits
Commits
Show all changes
12 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 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" xml:lang="en" xmlns="http://www.w3.org/1999/xhtml"><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" xml:lang="en" xmlns="http://www.w3.org/1999/xhtml"> | ||
|
||
<head> | ||
<meta http-equiv="Content-Type" content="text/html;charset=UTF-8" /> | ||
<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.</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>The <code class="language-html">aria-label</code> attribute can also be used to provide an accessible name for custom controls. Custom controls can’t use techniques for native HTML controls, like using a <code class="language-html"><label></code> element with the <code class="language-html">for</code> attribute. 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, it needs an accessible name provided by <code class="language-html">aria-label</code> or <code class="language-html">aria-labelledby</code>.</p> | ||
yatil marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
</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> | ||
<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"><div id="box"> | ||
This is a dialog. | ||
<button aria-label="Close">×</button> | ||
</div></code></pre> | ||
<p class="working-example">Working example: <a href="../../working-examples/aria-label-invisible-label-box/">Close button example</a>. | ||
</p> | ||
<p class="working-example">Working example: <a href="../../working-examples/aria-label-invisible-label-box/">Close button example</a>. | ||
yatil marked this conversation as resolved.
Show resolved
Hide resolved
|
||
</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"> | ||
<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> |
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This isn't accurate; you can't always use
aria-label
any time you want to give an accessible name to any arbitrary element. Notably, in the exact example implied by the following paragraphs (<div aria-label="whatever" contenteditable></div>
,aria-label
would not be allowed unless the author also gave thediv
an explicitrole
(because WAI-ARIA prohibits the use ofaria-label
andaria-labelledby
on elements withgeneric
roles, likediv
is by default)).There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@dbjorge, would this help?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.