Skip to content

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
wants to merge 11 commits into
base: main
Choose a base branch
from

Conversation

yatil
Copy link
Contributor

@yatil yatil commented Jul 3, 2025

Trying to be clear that aria-label sets the accessible name, also clarified some text. This technique could probably do with more examples of screen reader and voice input interactions, I’m not sure if readers understand what the impact really is and why it is important.

I also modernised the language from “lightbox” to dialog, but I left the example mostly as is for now. It would be good to update it to a proper <dialog> example.

My apologies for automatically re-indenting the file, but it is so difficult to work with these files otherwise.

yatil added 3 commits July 3, 2025 11:09
Sorry that this will make the actual PR more difficult to read, but it’s necessary to be able to efficiently make changes for me.
Trying to be clear that aria-label sets the accessible name, also clarified some text. This technique could probably do with more examples of screen reader and voice input interactions, I’m not sure if readers understand what the impact really is and why it is important.
@w3cbot
Copy link

w3cbot commented Jul 3, 2025

yatil marked as non substantive for IPR from ash-nazg.

Copy link

netlify bot commented Jul 3, 2025

Deploy Preview for wcag2 ready!

Name Link
🔨 Latest commit e1df541
🔍 Latest deploy log https://app.netlify.com/projects/wcag2/deploys/68664ed1335ec80007dea8bf
😎 Deploy Preview https://deploy-preview-4482--wcag2.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

Copy link

netlify bot commented Jul 3, 2025

Deploy Preview for wcag2 ready!

Name Link
🔨 Latest commit 0c8ea5b
🔍 Latest deploy log https://app.netlify.com/projects/wcag2/deploys/68712b53cd909f0008a408b6
😎 Deploy Preview https://deploy-preview-4482--wcag2.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

Copy link
Member

@patrickhlauke patrickhlauke left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

once the working example is modified as well, this looks good to me

Preview: https://deploy-preview-4482--wcag2.netlify.app/techniques/aria/aria14

patrickhlauke and others added 4 commits July 3, 2025 23:18
Working example is now using an html dialog and also some more styling, just to be fancy. I also synced the example back to the technique.
#Conflicts:
#	techniques/aria/ARIA14.html
@yatil yatil requested a review from patrickhlauke July 4, 2025 10:15
Co-authored-by: Hidde de Vries <hidde@hiddedevries.nl>
Copy link
Member

@hidde hidde left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great to me!

@patrickhlauke patrickhlauke self-assigned this Jul 4, 2025
@mbgower mbgower self-assigned this Jul 11, 2025
@kfranqueiro
Copy link
Contributor

HTML diff

<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.</p>
Copy link
Contributor

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 the div an explicit role (because WAI-ARIA prohibits the use of aria-label and aria-labelledby on elements with generic roles, like div is by default)).

</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>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">&lt;label&gt;</code> element with the <code class="language-html">for</code> attribute.</p>
Copy link
Contributor

@dbjorge dbjorge Jul 11, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Custom controls can’t use techniques for native HTML controls, like using a <label> element with the for attribute.

This isn't accurate either - you can absolutely use <label> elements as part of implementing some types of custom controls. A <label> is allowed to label anything that the HTML spec considers "labelable element", which includes, for example, form-associated custom elements

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not all though ... "custom controls" in the sense of, say, a mere <div> with a role etc can't be labelled with a <label>. so yeah, this needs to be mitigated/explained

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants