Use empty alt text for Pets component 'hero' image #5
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.
From step 7 onwards, the
Pet
component implements this code inside an<a>
or<Link>
element:The
name
prop used for the image alt text is duplicated in the contents of the adjacent H1, so my suggested change is to set the alt text attribute to empty:This will have the effect of making the image effectively invisible to screen reader users, but the current consensus is that this is desirable behaviour when the alt text would otherwise be duplicating adjacent text. In an ideal world the alt text would accurately describe the contents of the image (e.g. colour, fur type, position, background elements) of each pet, but
The
Carousel
component has a similar issue with redundant alt text (alt="animal"
andalt="animal thumbnail"
), but setting the alt text to blank would essentially make the carousel entirely empty to screen reader users, so I don't think this is addressable without reworking the entire component.References:
https://webaim.org/techniques/alttext/#context
https://rocketvalidator.com/accessibility-validation/axe/4.7/image-redundant-alt