question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Accessibility issue with labels in Registration Form course

See original GitHub issue

Describe the Issue

There are two related issues:

  • The label for the file input does not use a for attribute and this is causing the NVDA screen reader on Windows and ORCA screen reader on linux to not announce the label text when the user tabs to the input. I have a codepen demo to illustrate this.
  • It is considered a best practice to use a for attribute on a label, even when the input is embedded in the label itself, because some screen readers may not read the label correctly without the for attribute (as demonstrated in the issue above). This is also noted in step 30 of the Accessibility Quiz course.

All of the inputs on the form in this course are embedded in a label and none of the labels have a for attribute.

Affected Page

All steps of the Registration Form course that have inputs embedded in labels.

Your code

Current HTML for file input:

<label>Upload a profile picture: <input type="file" name="file" /></label>

Expected behavior

Should be something like:

<label for="file-upload">Upload a profile picture: <input id="file-upload" type="file" name="file" /></label>

Screenshots

No response

System

  • Device: Desktop
  • OS: Windows 11
  • Browser: Firefox
  • Version: 101
  • Screen Reader: NVDA
  • Version: 2022.1

Additional context

I’m only bringing this up because I thought it might be a good opportunity to teach campers that valid HTML isn’t always as accessible as it could be and best practices should be followed because they help eliminate these types of edge cases.

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:12 (12 by maintainers)

github_iconTop GitHub Comments

1reaction
JohnathanTWebstercommented, Jul 25, 2022

@Sboonny thank you. I will look into this further. I checked the documentation site for how to “edit” but there were only steps on how to create new challenges.

1reaction
JohnathanTWebstercommented, Jul 24, 2022

@Sboonny Okay, I can take a look. Since the concept is mentioned early on in the course I can start adding “for” in the labels.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Labeling Controls | Web Accessibility Initiative (WAI) - W3C
Provide labels to identify all form controls, including text fields, checkboxes, radio buttons, and drop-down menus. In most cases, this is done by...
Read more >
Accessibility issue because labels and forms controls are not ...
I am not sure if screen readers can successfully connect the label with the form controls, but I am sure it is not...
Read more >
Missing Input Labels: How to Fix a Common Accessibility Issue
Missing input labels can cause accessibility issues. By understanding the best practices of HTML, you can avoid common mistakes.
Read more >
Accessible Forms – Should Every Input Have a Label?
Input fields without accompanying labels can lead to accessibility issues for those who rely on screen readers. If a screen reader comes across ......
Read more >
Empty or Missing Form Label - Equalize Digital
If you see a missing or empty form label error in Accessibility Checker, the best course of action is to open your form...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found