Create an accessible language selector
Start with a visible language name. Flags alone can be ambiguous and their meaning depends on country rather than language.
Built-in link information
Each language link receives:
langfor the language of its label;hreflangfor its destination;rel="alternate";aria-current="page"when an included list or link represents the current locale.
Flag emoji wrappers are hidden from assistive technology. Flag images have alternative text based on the language label. Pair either flag form with readable text.
Dropdown behavior
Shortcode and floating dropdown toggles expose aria-haspopup="true" and an updated aria-expanded state. They respond to:
- mouse or pointer activation;
Enter;Space;ArrowDown;ArrowUp;Escape.
Keyboard opening moves focus to the first enabled language. The included current-language menu entry is disabled and removed from the tab sequence.
Navigation-menu dropdowns use the theme's normal nested-menu markup. Their accessibility depends on the theme's menu implementation, so do not assume the shortcode script controls them.
Run a keyboard review
- Tab to the selector.
- Open it without a pointer.
- Confirm focus reaches a selectable locale.
- Move through the available links.
- Close it with
Escape. - Continue tabbing through the page.
- Repeat at 200% zoom and on the theme's mobile menu.
Also inspect the accessible name after applying custom markup. Decorative punctuation, an empty custom label, or a flag-only template can leave the link unclear even when the HTML is technically valid.