OnlineNexusAccess accessibility home Free scan

How to make pop-ups and newsletter modals accessible

"Get 10% off your first order" pop-ups are everywhere. For a keyboard or screen reader user they can block the whole store: focus stays on the page behind, the close "X" can't be reached or has no name, and nobody announces that a pop-up appeared. This guide shows how to test yours in a minute and what a correct pop-up does.

Step 1: Test your pop-up

  1. Open your store in a private browser window so the pop-up appears, and don't touch the mouse.
  2. Press Tab. Does focus go into the pop-up, and can you see it?
  3. Can you reach and use the email field, the submit button and the close button?
  4. Press Escape. Does the pop-up close?
  5. After it closes, does focus land somewhere sensible, such as where you were?

Then try the same with a screen reader (VoiceOver on Mac, NVDA on Windows). You should hear that a dialog opened, its title, and the label of the email field.

What an accessible pop-up does

A pop-up that covers the page is a modal dialog. The W3C's ARIA Authoring Practices describe how one should work: focus moves into it when it opens, Tab stays inside it, Escape closes it, and focus returns to where it was when it closes (Dialog (Modal) Pattern (W3C WAI-ARIA Authoring Practices Guide)). The dialog should have an accessible name, usually from its visible title.

Accessible newsletter pop-up (HTML + JavaScript)
<dialog class="newsletter" aria-labelledby="nl-title">
  <button type="button" class="nl-close" aria-label="Close">
    <svg aria-hidden="true" focusable="false"><!-- X icon --></svg>
  </button>
  <h2 id="nl-title">Get 10% off your first order</h2>
  <form method="post" action="/contact#newsletter">
    <label for="nl-email">Email address</label>
    <input id="nl-email" type="email" name="contact[email]" autocomplete="email" required>
    <button type="submit">Subscribe</button>
  </form>
</dialog>

<script>
  const nl = document.querySelector('.newsletter');
  const returnTo = document.activeElement;
  nl.showModal();                       // page behind becomes inert; Escape closes
  nl.querySelector('.nl-close').addEventListener('click', () => nl.close());
  nl.addEventListener('close', () => returnTo && returnTo.focus && returnTo.focus());
</script>

Using <dialog> with showModal() makes the rest of the page inert while the pop-up is open, and the Escape key closes it on desktop browsers (<dialog>: The Dialog element (MDN Web Docs)).

Step 2: Give the close button a name

An "X" icon on its own has no text for a screen reader. Add an accessible name such as "Close" (an aria-label or visually hidden text), and make the button at least 24 by 24 pixels, which is the WCAG 2.2 minimum target size, with exceptions (Understanding Success Criterion 2.5.8: Target Size (Minimum) (W3C WAI)). Our guide to icon buttons with no name has more examples. A visible "No thanks" text button is even better.

Step 3: Label the email field

Placeholder text like "Enter your email" disappears when you type and isn't a reliable label. Use a real <label>, and announce success or errors as text, not color alone. See unlabeled form fields.

Step 4: Don't let banners hide keyboard focus

Cookie banners and slide-in bars usually aren't modal, so shoppers keep using the page underneath. WCAG 2.2's 2.4.11 Focus Not Obscured asks that a focused element is not entirely hidden by content you added (Understanding Success Criterion 2.4.11: Focus Not Obscured (Minimum) (W3C WAI)). If your cookie bar covers the bottom of the screen, check that tabbing down the page never moves focus underneath it. Keep the bar short, or add bottom padding to the page while it is shown.

Step 5: Avoid surprise timing

  • Countdown offers: if a pop-up gives shoppers a limited time to do something, WCAG 2.2.1 Timing Adjustable asks that they can turn off, adjust or extend the time limit, with some exceptions (Understanding Success Criterion 2.2.1: Timing Adjustable (W3C WAI)). A countdown that only displays urgency and doesn't end any session is less of a problem, but it shouldn't move or flash.
  • Delay: showing the pop-up after a few seconds or on exit is fine, but don't show it again after it has been closed.
  • Auto-closing messages: a "Thanks for subscribing" message that disappears after two seconds may vanish before someone has read it. Leave it until the shopper closes it.

Shopify and WooCommerce: what to ask your pop-up app

Most stores use an app or plugin for pop-ups, so you may not control the code. Run the test above, and if it fails, send the developer a specific list: focus doesn't move into the pop-up, Escape doesn't close it, the close button has no name, the email field has no label. If it can't be fixed, consider a different app or an inline signup form in your footer, which avoids all of these problems. See how to check Shopify apps.

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

Common questions

Are pop-ups bad for accessibility in general?

Not if they follow the dialog pattern. The problems come from pop-ups that ignore the keyboard and screen readers.

Should the pop-up appear on mobile?

That is a design choice. If it does, make sure it fits small screens without hiding the close button, and works when zoomed in.

Can the scanner test pop-ups?

Our scanner finds problems like unnamed buttons and unlabeled fields if the pop-up is on the page when it runs. It can't judge focus movement, so do the keyboard test too.

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