Accessibility Improvement: Close buttons to use visually-hidden text instead of aria-labels #41587
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.
Description
One thing I always have in my mind when building accessible components is 'the better this works without any CSS the better', (and 'the better this works without JavaScript the better') so from time to time I disable one or the other and see if any improvements can be made.
With that in mind, when working on a standard Bootstrap alert (with dismiss button) from the example code I noticed it appears like this with CSS disabled:
Because the
.btn-close
is like this:I think this could be improved with the following:
So it appears like this:
Motivation & Context
It does mean a few more characters/bytes of markup added but I believe it's worth it. it makes the content more resilient and usable even if CSS for any reason fails to load.
Also, aria-labels are not always auto-translated for users reading the content in a different language, but using a visually hidden text label would be translated - another potential accessibility benefit. REF: https://adrianroselli.com/2019/11/aria-label-does-not-translate.html
Type of changes
Checklist
npm run lint
)Live previews
Related issues
Fixes: #41580