I have a <button>
element that opens a modal to change the webpage region and/or language.
The <button>
element needs an aria-label that gives the user information about what the modal does. The button text is the current selected language.
My current code:
<button id="languageButton" aria-label="Change Region and/or Language">
Norway (English)
</button>
According to this article: https://dequeuniversity.com/rules/axe/4.7/label-content-name-mismatch
The following examples pass the Label and name from content mismatch rule:
Full visible label is contained in the accessible name.
<button name="link" aria-label="Next Page in the list">Next Page</button>
The following examples fail the Label and name from content mismatch rule:
Visible label doesn’t match accessible name.
<div role="link" aria-label="OK">Next</div>
Not all of visible label is included in accessible name.
<button name="link" aria-label="the full">The full label</button>
So based on this article, what would be the optimal button text and aria-label for a button that opens a modal to change the language in regards to WCAG?
If i set both the button text and aria-label to "Change region and/or language from Norway (English)
" where "Norway (English)
" is dynamically set to the current selected region and language, it would be valid, but ugly.
<button id="languageButton" aria-label="Change region and/or language from Norway (English)">
Change region and/or language from Norway (English)
</button>
Any suggestions for a better way?