WordPress fix

Before and after

Broken — before
<?php // header.php (Broken: role="menubar" without role="none" / role="menuitem") ?>
<nav aria-label="<?php esc_attr_e( 'Primary menu', 'mytheme' ); ?>">
  <?php
  wp_nav_menu( array(
    'theme_location' => 'primary',
    'items_wrap'     => '<ul id="%1$s" class="%2$s" role="menubar">%3$s</ul>',
  ) );
  ?>
</nav>
Fixed — after
<?php // header.php (Fixed: clean semantic <ul> navigation inside <nav> landmark) ?>
<nav aria-label="<?php esc_attr_e( 'Primary menu', 'mytheme' ); ?>">
  <?php
  wp_nav_menu( array(
    'theme_location' => 'primary',
    'container'      => false,
    'items_wrap'     => '<ul id="%1$s" class="%2$s">%3$s</ul>',
  ) );
  ?>
</nav>
Live preview

Fixed vs. broken example

Passes aria-required-children
Accessibility tree: role="tablist" directly owns role="tab" (selected, 1 of 2) and role="tab" (unselected, 2 of 2)

Remove extraneous intermediate wrapper <div>s between a composite ARIA parent and its required children—or set role="none" on purely structural wrappers.

Automated test

Playwright + axe-core check

tests/a11y-aria-required-children.spec.ts
import { test, expect } from "@playwright/test";
import AxeBuilder from "@axe-core/playwright";

test("WordPress header navigation and WooCommerce tabs pass aria-required-children", async ({ page }) => {
  await page.goto("/");
  const results = await new AxeBuilder({ page })
    .withRules(["aria-required-children"])
    .analyze();
  expect(results.violations).toEqual([]);
});

Template deduplication tip

A misconfigured role='menubar' in header.php or a custom Walker_Nav_Menu fires on 100% of WordPress posts and pages. Fixing that single PHP walker clears every route in one deploy.

Screen readers

What NVDA and VoiceOver announce

When a container declares role='tablist', role='menu', or role='listbox' without directly owning its required child roles (tab, menuitem, option), assistive technologies break arrow-key navigation, item counts ('1 of 3'), and selection state announcements.

NVDA (Windows)

Broken

"Product details, tab control" -> "Specs, button" (item count and selected tab semantics lost)


Fixed

"Product details, tab control, Specs, tab, selected, 1 of 2"

VoiceOver (macOS / iOS)

Broken

"Product details, tab group, 0 items" -> "Specs, button"


Fixed

"Specs, selected, tab, 1 of 2, Product details, tab group"

Common questions

Why do WooCommerce single-product tabs sometimes fail aria-required-children?
Older theme overrides of templates/single-product/tabs/tabs.php leave <li class='description_tab'> inside <ul class='tabs wc-tabs' role='tablist'> without setting role='presentation' on the <li> and role='tab' on the inner link.
Should WordPress dropdown navigation menus ever use role='menubar'?
Almost never for websites. Standard WordPress <nav><ul><li> links plus <button aria-expanded> toggles for submenus provide far better screen-reader and keyboard ergonomics.
How can I fix broken ARIA roles injected by a WordPress plugin?
Use the theme template override directory (e.g., yourtheme/woocommerce/...) or hook into render_block / wp_nav_menu_items in functions.php to sanitize invalid roles before HTML hits the browser.