WordPress fix

Before and after

Broken — before
<?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>
Fixed — after
<?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>
Live preview

Fixed vs. broken example

Passes button-name
Accessibility tree: role="button", accessible name="Open site search" (decorative SVG hidden with aria-hidden="true")

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".

Automated test

Playwright + axe-core check

tests/a11y-button-name.spec.ts
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.

Screen readers

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)

Broken

"button" (silence — no action name announced)


Fixed

"Open site search, button"

VoiceOver (macOS / iOS)

Broken

"button" (unlabeled interactive element)


Fixed

"Open site search, button"

Common questions

Is .screen-reader-text built into WordPress core CSS?
WordPress core and all accessibility-ready themes ship .screen-reader-text styles, though custom themes should verify the CSS rule is included in style.css so visually hidden labels stay off-screen cleanly.
What if a third-party WordPress plugin injects an unlabeled button?
Check whether the plugin exposes a template override or PHP render filter (such as render_block). For Gutenberg blocks, use the render_block filter in functions.php to inject an aria-label server-side without modifying core plugin files.
Why add aria-hidden='true' to Dashicons or FontAwesome spans?
Icon font glyphs use Private Use Area Unicode characters that some screen readers pronounce as gibberish or 'blank' unless explicitly hidden with aria-hidden='true'.