OnlineNexusAccess accessibility home Free scan

How to fix icon buttons and links with no name (cart, search, menu and social icons)

Look at the top of most online stores and you'll see a row of small icons: a magnifying glass, a person, a bag, three lines for the menu. Sighted shoppers recognise them instantly. A screen reader user often hears only "button" or "link", with no idea what it does. This is one of the most frequent problems automated scans find, and one of the easiest to fix.

Why icons need a text name

Screen readers announce each interactive element by its name and its role, for example "Cart, link" or "Open menu, button". WCAG success criterion 4.1.2 requires that interface components have a name that software can determine (Understanding Success Criterion 4.1.2: Name, Role, Value (W3C WAI)), and 2.4.4 requires that the purpose of each link can be worked out from its text or context (Understanding Success Criterion 2.4.4: Link Purpose (In Context) (W3C WAI)).

An icon drawn with an SVG or an icon font has no text, so unless the theme adds some, the element's name is empty. Automated tools such as axe-core report these as "Buttons must have discernible text" (button-name) and "Links must have discernible text" (link-name). In our own 10-store test sample, links with no readable name turned up on 6 of the 10 stores, 81 links in total (see the most common problems we found).

Where to look

Typical offenders on Shopify and WooCommerce stores:

  • Header icons: search, account, cart, wishlist and the mobile menu ("hamburger") button.
  • Social media links in the footer (Instagram, Facebook, TikTok icons).
  • Slideshow arrows and dots, and the close "X" on pop-ups and drawers.
  • Quantity plus and minus buttons, and "remove item" buttons in the cart.
  • Product card links that wrap only an image with no alt text.

To find them quickly, run our free scan, which lists them by page, or use your browser's developer tools: right-click an icon, choose Inspect and look at the Accessibility pane, which shows the computed name. If the name is empty, it needs fixing.

The fix, in one sentence

Give every icon-only control a short text name, and hide the icon itself from assistive technology. There are two common ways to add the name:

  • Visually hidden text inside the button or link. It is read by screen readers and translation tools but not shown on screen. Shopify themes such as Dawn include a visually-hidden class, and WordPress themes use screen-reader-text.
  • An aria-label attribute on the button or link. This works well, but automatic page translation tools don't always translate attribute values, so visible or visually hidden text is often the more robust choice.

Then add aria-hidden="true" and focusable="false" to the SVG so it isn't announced as an unnamed image.

Shopify: header cart and search icons

Theme code differs, but the pattern is the same in most themes. Find the icon in sections/header.liquid (or a snippet it renders) and make sure it looks something like this:

sections/header.liquid (excerpt): cart and search icons
<a href="{{ routes.cart_url }}" class="header__icon header__icon--cart" id="cart-icon-bubble">
  <svg aria-hidden="true" focusable="false" class="icon icon-cart" viewBox="0 0 40 40">...</svg>
  <span class="visually-hidden">
    {{- 'templates.cart.cart' | t -}}
    {%- if cart.item_count > 0 %}, {{ cart.item_count }} items{% endif -%}
  </span>
</a>

<a href="{{ routes.search_url }}" class="header__icon header__icon--search">
  <svg aria-hidden="true" focusable="false" class="icon icon-search" viewBox="0 0 20 20">...</svg>
  <span class="visually-hidden">Search</span>
</a>

The 'templates.cart.cart' | t filter reads the word "Cart" from your theme's language file so it matches your store's language. If your theme does not have that translation key, plain text such as Cart works too.

snippets/social-icons.liquid (excerpt)
{%- if settings.social_instagram_link != blank -%}
  <li>
    <a href="{{ settings.social_instagram_link }}" class="link list-social__link">
      <svg aria-hidden="true" focusable="false" class="icon icon-instagram">...</svg>
      <span class="visually-hidden">Instagram</span>
    </a>
  </li>
{%- endif -%}

If your theme doesn't have a visually-hidden class, add one to your theme's CSS file:

assets/base.css (or your theme's main CSS file)
.visually-hidden {
  position: absolute !important;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

Shopify: the mobile menu button

Menu buttons need a name and should tell screen readers whether the menu is open. If your theme uses a plain <button>, add a label and keep aria-expanded in sync with your theme's JavaScript:

sections/header.liquid (excerpt): mobile menu button
<button type="button" class="header__menu-toggle"
        aria-controls="menu-drawer" aria-expanded="false">
  <svg aria-hidden="true" focusable="false" class="icon icon-hamburger">...</svg>
  <span class="visually-hidden">Menu</span>
</button>

Many Shopify themes, including Dawn, use a <details> and <summary> element for the menu, which reports open and closed states automatically. In that case only the text name is needed.

WooCommerce: mini-cart and header icons

In WordPress themes, header icons are usually in header.php or a template part. Copy the file into a child theme first (Child Themes (WordPress Theme Handbook)) and edit the copy. A cart icon link with a proper name looks like this:

wp-content/themes/your-child-theme/header.php (excerpt)
<a class="header-cart" href="<?php echo esc_url( wc_get_cart_url() ); ?>">
  <svg aria-hidden="true" focusable="false" class="icon" viewBox="0 0 24 24">...</svg>
  <span class="screen-reader-text">
    <?php
    printf(
        /* translators: %d: number of items in the cart */
        esc_html__( 'Cart, %d items', 'your-child-theme' ),
        (int) WC()->cart->get_cart_contents_count()
    );
    ?>
  </span>
</a>

WordPress core and most themes already style the screen-reader-text class so it is hidden visually. Block themes built with the Site Editor use WooCommerce's Mini-Cart block, which handles its own labelling; if you see an unlabeled cart there, check for a plugin or custom HTML block replacing it.

WooCommerce: icon buttons added by plugins

Wishlist, compare and quick-view plugins often add icon-only buttons to product cards. If the plugin has a setting to show text labels, turn it on. If not, ask the plugin developer to add an accessible name; WooCommerce's own extension guidelines ask developers to follow accessibility best practices (Accessibility Best Practices for extensions (WooCommerce developer docs)). Editing a plugin's files directly is not a good idea, because updates overwrite them.

Check your own store in a minute or two. Our free scanner opens your homepage, a collection page, a product page and your cart in a real browser and lists the problems it can detect automatically, in plain English.

Run the free scan

How to check your fix

  1. Reload the page and inspect the icon again: the Accessibility pane should now show a name such as "Cart, 2 items".
  2. Run the scan again: the button-name and link-name results for those elements should be gone.
  3. If you can, try a screen reader: VoiceOver is built into Macs and iPhones and NVDA is free for Windows. Tab to the icon and listen.

Common mistakes

  • Using title as the only name. Tooltips are not reliably announced and don't appear for keyboard or touch users.
  • Naming the icon, not the action. "Magnifying glass" describes the picture; "Search" describes what happens.
  • Repeating the name twice. If the button already has visible text, don't add an aria-label that says something different; screen reader users would hear a name that doesn't match what sighted users see.
  • Hiding the whole button. aria-hidden="true" belongs on the decorative SVG, never on the button or link itself.

Common questions

Should I use aria-label or visually hidden text?

Both work. Visually hidden text inside the link or button is translated by browser translation tools and is easy to see in the theme code; aria-label is quicker to add to an existing element. Pick one per element, not both, and make sure the words match what the icon does.

Does the cart icon need to say how many items are in the cart?

It helps. A name like "Cart, 2 items" tells people what they will find before they open it. Most themes already print the count as a small badge; make sure that number is part of the link's name, or inside it as visually hidden text, rather than a separate element that is read out of context.

What about icons that are only decoration?

Hide them from assistive technology with aria-hidden="true" on the SVG or icon font element, and make sure focusable elements are never hidden that way. If an icon sits next to visible text that already says the same thing, such as a truck icon beside "Free shipping", it is decoration.

Will fixing these change how my store looks?

No. A text name added this way is not visible on screen, so the design stays exactly the same. Only people using screen readers, voice control or other assistive technology notice the difference.

Technical fixes, not legal advice. This guide explains website accessibility from a technical point of view. We are not a law firm, and nothing here is legal advice. No scan, fix or guide can guarantee legal compliance, the outcome of any demand letter or lawsuit, or protection from future claims. If you have received a legal claim, please consult a qualified attorney about it.

Sources