Fix button-name in WordPress
Classic and hybrid WordPress themes frequently ship FontAwesome or Dashicons icon buttons inside header.php and searchform.php with empty inner text. Using WordPress's native .screen-reader-text utility class alongside esc_html_e() or esc_attr_e() gives every icon control a translated, WCAG-valid accessible name.
Before and after
<?php // header.php (Broken WordPress mobile navigation button) ?>
<button type="button" class="menu-toggle" data-toggle="nav">
<span class="dashicons dashicons-menu-alt3"></span>
</button><?php // header.php (Fixed with WordPress .screen-reader-text & escaped i18n label) ?>
<button
type="button"
class="menu-toggle"
aria-controls="primary-navigation"
aria-expanded="false"
>
<span class="dashicons dashicons-menu-alt3" aria-hidden="true"></span>
<span class="screen-reader-text"><?php esc_html_e( 'Open primary navigation', 'mytheme' ); ?></span>
</button>Fixed vs. broken example
Tab to each button and inspect the Accessibility pane in DevTools: the broken control exposes an empty Name while the fixed control exposes "Open site search".
Playwright + axe-core check
import { test, expect } from "@playwright/test";
import AxeBuilder from "@axe-core/playwright";
test("WordPress header & search form buttons pass button-name", async ({ page }) => {
await page.goto("/");
const results = await new AxeBuilder({ page })
.withRules(["button-name"])
.analyze();
expect(results.violations).toEqual([]);
});Template deduplication tip
An unlabeled mobile toggle in header.php or search submit icon in searchform.php triggers on every WordPress post, page, and WooCommerce category. Fixing that single PHP partial clears 100% of affected routes in A11yDrift.
What NVDA and VoiceOver announce
Blind screen-reader users and voice-dictation users (Dragon, Voice Control) encounter unlabeled icon buttons as generic 'button' controls with no clue whether activating them opens search, closes a modal, or deletes an item.
NVDA (Windows)
"button" (silence — no action name announced)
"Open site search, button"
VoiceOver (macOS / iOS)
"button" (unlabeled interactive element)
"Open site search, button"
Common questions
Is .screen-reader-text built into WordPress core CSS?
What if a third-party WordPress plugin injects an unlabeled button?
Why add aria-hidden='true' to Dashicons or FontAwesome spans?
Test a URL for button-name
Enter any public URL for a free WCAG 2.2 AA check—no account or credit card required.
Managing WordPress client sites? Monitor 15 sites on one flat plan with white-label portals and branded executive PDFs—$1,140/yr ($95/mo billed annually, 24-month rate lock + onboarding) for Founding 10 agencies.