Skip to content
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

Add alt attribute to image inside <figure> element to improve accessibility #275

Open
manav-sharma69 opened this issue Jul 1, 2024 · 1 comment · May be fixed by #276
Open

Add alt attribute to image inside <figure> element to improve accessibility #275

manav-sharma69 opened this issue Jul 1, 2024 · 1 comment · May be fixed by #276

Comments

@manav-sharma69
Copy link

What information was incorrect, unhelpful, or incomplete?

Link to live example: Basic View Transitions API demo


Improve incomplete code:

  • The image in <figure> element do not have an alt attribute.
  • According to W3's documentation, we should add the alt attribute whenever possible.
  • In this example's case, all images have a name in imageData array. So, we do have alt but haven't added them in the image in <figure> element.
  • The image in anchor elements do have alt attribute added:

anchorWithAlt

What did you expect to see?

In the script.js file, I suggest adding the following code:

galleryImg.alt = imageData[0].name; // in the init() function
galleryImg.alt = targetIdentifier.alt; // in the displayNewImage() method inside updateView() function

Do you have any supporting links, references, or citations?

"If there is even the slightest possibility of the author having the ability to provide real alternative text, then it would not be acceptable to omit the alt attribute." - W3's documentation

Do you have anything more you want to share?

Upon reviewer's approval, I'll create a PR to fix this issue.

@manav-sharma69 manav-sharma69 added the needs triage Triage needed by staff and/or partners. Automatically applied when an issue is opened. label Jul 1, 2024
@bsmth bsmth removed the needs triage Triage needed by staff and/or partners. Automatically applied when an issue is opened. label Jul 2, 2024
@bsmth
Copy link
Member

bsmth commented Jul 2, 2024

Thanks a lot for opening, I think you can go ahead and create a PR for this 👍🏻

@manav-sharma69 manav-sharma69 linked a pull request Jul 2, 2024 that will close this issue
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 a pull request may close this issue.

2 participants