Check 40.02 · AI agent compatibility

Identify what each button does

Give every button a name that states the action and its object, unique on the page, so an AI agent clicks the right one, on WordPress, Shopify, Laravel or Next.js.

Priority
Experimental
Difficulty
Easy
Estimated time
1 h to 1 day
Free, no account: your progress is saved in this browser.

Ask an AI to check this point on your site

Opens the assistant with a ready-made question: this check, its goal and your site URL.

For Gemini, Copilot or another assistant, copy the question. The link opens the chosen service directly: nothing goes through this site.

In short

An AI agent decides what to click based on button names: the visible text, or the accessible name computed by the browser. “OK”, “Submit”, an icon with no text or ten identical “Add” buttons force it to guess. Once this check is done, every button in your key journeys carries a name that describes the action and its object (“Add the Alpine jacket, size M, to cart”), that name is unique in its context, and irreversible actions stand out clearly from the others. This topic is experimental: no agent documents its selection algorithm precisely.

Why it matters

When it works on the accessibility tree, an agent sees a list such as button "Add", button "Add", button "". Microsoft's Playwright MCP server, for example, identifies elements by their role and name in this tree before clicking. Two buttons with the same name cannot be told apart; a button without a name has no known function. When it works on a screenshot, the agent reads the same labels in the image: a lone trash-can icon can mean “empty the cart” or “remove this item”.

The consequences are concrete: the wrong product added to the cart, a deletion instead of an edit, a loop of attempts that ends in abandonment. Consumer agents are designed to ask for confirmation before important actions; OpenAI states, for example, that ChatGPT agent asks for permission before consequential actions. A button whose name precisely describes the action makes that confirmation understandable for the user.

WCAG (Web Content Accessibility Guidelines) success criterion 4.1.2 requires a name for every component, criterion 2.4.6 requires labels that describe their purpose, and criterion 2.5.3 requires the name to contain the visible label.

What it improves

  • Agent reliability Fewer ambiguous clicks and wrong actions. A plausible effect, not publicly measured.
  • Accessibility Screen readers announce buttons that make sense out of context, especially in the list of buttons they offer.
  • Voice control Users can say the visible label to click.
  • Conversion Precise action labels (“Pay €89.00”) reduce hesitation. An effect to measure on your own site.
  • Rankings No direct effect.

How to check

Console inventory. Paste this script into the browser console. It approximates the names (it ignores aria-labelledby and image alt text) and counts duplicates:

const boutons = [...document.querySelectorAll('button, [role="button"], input[type="submit"], input[type="button"]')];
const noms = boutons.map((el) => (el.getAttribute('aria-label') || el.textContent || el.value || '').replace(/\s+/g, ' ').trim() || '(no name)');
const compte = noms.reduce((acc, nom) => ({ ...acc, [nom]: (acc[nom] || 0) + 1 }), {});
console.table(Object.entries(compte).sort((a, b) => b[1] - a[1]));

Compliant result: no “(no name)” row, and names repeated several times are either identical actions (“Close”) or completed with context.

Exact name. For doubtful cases, open Chrome DevTools, the Elements panel, the Accessibility tab: the “Name” row of the computed properties gives the name actually exposed. The ARIA snapshot script in the guide use semantic HTML and explicit labels (opens in a new tab) lists every button on a page.

Automated audit. axe DevTools and Lighthouse report the button-name rule (button without an accessible name); WAVE reports “Empty button”.

How to implement

Before you start

Take an inventory of the buttons in your key journeys in a table:

Page Visible label Accessible name Actual action Reversible? Fix
Product list Add Add adds the card's product to the cart yes “Add to cart” + product name as context
Cart trash-can icon (empty) removes the line yes name “Remove Alpine jacket from cart”
Cart Empty Empty deletes the whole cart not without re-entering it “Empty cart”, distinct style, confirmation
Checkout Submit Submit payment and order no “Pay €89.00 and place order”
Account Delete Delete deletes the account no “Delete my account”, confirmation

Naming rules:

  • Verb + object: “Download the March invoice”, “Add to cart”, “Book this slot”. Not “OK”, “Submit” or “Continue” on their own when the action commits the user.
  • The visible label at the start of the accessible name: if the button reads “Add”, the name starts with “Add”. Context comes after, as visually hidden text or through aria-describedby.
  • One unique name per context: in a list, each button mentions its item.
  • The name follows the action, not the state: for a toggle button, keep the same name (“Add to favorites”) and expose the state with aria-pressed (see make component states accessible (opens in a new tab)).
  • Always an explicit type: type="submit" to submit, type="button" for everything else. Without a type, a button inside a form submits the form.
  • Link or button: a button acts, a link leads to another address. See distinguish action buttons from navigation links (opens in a new tab).
  • Irreversible actions set apart: a distinct style, kept away from frequent actions, and followed by a confirmation step (see require confirmation for sensitive actions (opens in a new tab)).

The three naming techniques, ready to paste:

<!-- 1. Full visible text -->
<button type="submit">Pay €89.00 and place order</button>

<!-- 2. Short visible text, visually hidden context -->
<button type="button" class="ajouter-panier">
  Add<span class="visually-hidden"> the Alpine jacket, size M, to cart</span>
</button>

<!-- 3. Icon button: name through aria-label, icon hidden -->
<button type="button" aria-label="Remove the Alpine jacket from cart">
  <svg aria-hidden="true" focusable="false" width="20" height="20"><use href="#icone-corbeille"></use></svg>
</button>

The visually-hidden class is the one from the guide check form labels (opens in a new tab). Do not use title as the only source of the name: it does not show up with the keyboard or on mobile.

Good to know: an aria-label replaces all the text of the button. If it does not include the visible label (“Add” displayed, aria-label="Buy"), the button becomes inconsistent for voice control and for an agent that compares the screenshot with the accessibility tree.

WordPress

Versions WordPress 6.5 and later, WooCommerce 9 and 10, November 2026.

  • WooCommerce: the “Add to cart” buttons in product lists already carry an aria-label that includes the product name. Check that a theme or a plugin has not removed it by overriding the loop/add-to-cart.php template.
  • Buttons block: it outputs links. For an action, use the submit button of a form plugin and set its label in the plugin (“Send my quote request” rather than “Send”).
  • Theme icon buttons (search, menu, cart): check their name in the Accessibility tab. If it is missing, add it in the child theme template:
<button type="button" class="ouvrir-recherche" aria-label="<?php echo esc_attr__( 'Open search', 'mon-theme' ); ?>">
    <?php echo mon_theme_icone( 'loupe' ); ?>
</button>

Shopify

Versions Online Store 2.0 themes, Liquid, November 2026.

In a collection product card, complete the quick add button with the product name:

<button type="submit" name="add" class="button">
  {{ 'products.product.add_to_cart' | t }}
  <span class="visually-hidden">{{ card_product.title | escape }}</span>
</button>

For the cart's icon buttons, reuse the following pattern with a theme translation key:

<button type="button" class="button button--tertiary" aria-label="Remove {{ item.product.title | escape }} from cart">
  {% render 'icon-remove' %}
</button>

The labels of checkout buttons are managed by Shopify.

PrestaShop

Versions PrestaShop 8 and 9, Classic theme.

The “Add to cart” label comes from the translations (International > Translations, theme translations). The Classic theme does not display this button in list thumbnails, only a quick view; if your theme or a module adds it, complete it in the child theme's thumbnail template (often templates/catalog/_partials/miniatures/product.tpl) with the product name:

<button class="btn btn-primary add-to-cart" data-button-action="add-to-cart" type="submit">
  {l s='Add to cart' d='Shop.Theme.Actions'}
  <span class="visually-hidden">{$product.name}</span>
</button>

Adapt the hiding class to your theme's (Bootstrap provides visually-hidden or sr-only depending on its version).

Laravel

Versions Laravel 11 to 13.

A Blade component that requires a name prevents anonymous buttons:

{{-- resources/views/components/bouton-icone.blade.php --}}
@props(['label', 'icone'])

<button type="button" aria-label="{{ $label }}" {{ $attributes }}>
    <x-dynamic-component :component="'icones.'.$icone" aria-hidden="true" />
</button>
<x-bouton-icone :label="__('Remove :produit from cart', ['produit' => $ligne->nom])" icone="corbeille" wire:click="retirer({{ $ligne->id }})" />

Next.js

Versions Next.js 15 and 16 (App Router).

Type the name as required in the component:

import type { ButtonHTMLAttributes, ReactNode } from 'react';

type BoutonIconeProps = ButtonHTMLAttributes<HTMLButtonElement> & { label: string; icone: ReactNode };

export function BoutonIcone({ label, icone, type = 'button', ...props }: BoutonIconeProps) {
  return (
    <button type={type} aria-label={label} {...props}>
      <span aria-hidden="true">{icone}</span>
    </button>
  );
}

In a list, build the label from the data: label={`Remove ${ligne.nom} from cart`}. In an automated test, Playwright finds the button by its role and name (page.getByRole('button', { name: 'Remove Alpine jacket from cart' })): if the test cannot find it, neither can an agent.

Common mistakes

  • Icon buttons without a name: magnifying glass, cross, heart, trash can. The most frequent finding in audits.
  • An aria-label that contradicts the visible text: “Add” displayed, “Buy now” announced.
  • Ten “Learn more” or “Add” buttons with no context in a list.
  • A label that changes with the state (“Follow” becomes “Unfollow”) with no exposed state: the agent does not know whether it has already clicked.
  • A payment button named “Continue”: neither the user nor the agent sees that they are committing to a payment.
  • A disabled button with no explanation: see provide clear error messages (opens in a new tab).
  • Different labels for the same action on two pages (“Add to cart”, “Buy”, “I want it”): consistency helps humans and agents recognize the action.

Frequently asked questions

How does an AI agent choose which button to click?

An AI agent chooses based on the button's name and its context. If it reads the accessibility tree, it sees the “button” role and the name computed by the browser; if it works on a screenshot, it reads the displayed text. In both cases, a name that describes the action and its object, unique on the page, prevents mistakes. No vendor publishes the details of its selection criteria.

aria-label or visually hidden text: which should you choose?

Both provide an accessible name. Visually hidden text completes a visible label, for example “Add” followed by the product name, and machine translation tools translate it along with the rest of the page. The aria-label attribute suits buttons that contain only an icon. In every case, the name must start with the visible label when there is one.

Does every “Add to cart” button in a list need a different label?

Yes, each button's accessible name must mention its product, even if the visible text stays “Add to cart”. Otherwise, a screen reader or an agent going through the list of buttons sees ten identical controls and cannot tell which one matches the product it wants. Add the product name as visually hidden text, or link the button to the card's title with aria-describedby.

Can a button lead to another page?

It is not recommended. A button triggers an action on the page; a change of address belongs to a link with an href attribute, which crawlers know how to follow and which agents can open or share. If the design requires it, give the link the look of a button with CSS. Reserve button elements for submitting forms, opening panels and actions that do not change the page.

Updated on

Topic checklist (PDF)

And now?

In the “AI agent compatibility” topic

  1. Use semantic HTML and explicit labels
  2. Identify what each button does
  3. Provide clear error messages
  4. Keep URLs stable
  5. Avoid mandatory complex gestures
  6. Make component states accessible
  7. Display final prices, availability and options
  8. Simplify booking and checkout
  9. Document existing public APIs
  10. Use OpenAPI if relevant
  11. Evaluate MCP based on use cases
  12. Evaluate compatible agentic commerce protocols
  13. Check authentication and authorization
  14. Require confirmation for sensitive actions
  15. Test user journeys with browsing agents
  16. Prevent prompt injection and unauthorized interactions