Accessibility Certified – Home

Cookie banners that lock no one out

The cookie banner is often the first thing visitors meet, and for some the last: if it cannot be used with a keyboard or screen reader, the site is closed to them. Here is how to get it right.

Last reviewed: · 5 min read

Why the banner matters so much

The banner sits in front of everything else. If it cannot be dismissed, the whole site is blocked. Common causes: the “buttons” are not real buttons, focus lands behind the banner where no one can see it, or the banner covers all content when text is enlarged.

Whether your banner meets data protection rules is a separate question; regulators often expect refusing to be as easy as accepting. Please check that with your privacy adviser. From an accessibility point of view the advice points the same way: two equal, clearly visible buttons help everyone.

Real buttons, not clickable boxes

Every action needs an element that works with the keyboard (2.1.1 Keyboard) and exposes its role and name to assistive technology (4.1.2 Name, Role, Value). A <button> does both out of the box.

Problem
<div class="btn" onclick="accept()">
  OK
</div>
Better
<button type="button" id="cc-accept">
  Accept all
</button>
<button type="button" id="cc-reject">
  Necessary only
</button>

The button can be focused, reacts to Enter and Space and is announced as a button. Its label says what happens.

Mark it up as a named dialog

If the banner behaves like a dialog, mark it up as one: role="dialog" with a name via aria-labelledby. Add aria-modal="true" only if the rest of the page really is blocked while it is open. Our modal dialog pattern shows the full behaviour.

Problem
<div class="cookie-layer">
  <p>We use cookies …</p>
</div>
Better
<div role="dialog" aria-labelledby="cc-h"
     aria-describedby="cc-p">
  <h2 id="cc-h">Cookie settings</h2>
  <p id="cc-p">We use cookies …</p>
</div>

Focus: in, visible and out again

  • Reachable: move focus into the dialog when it opens, or place a non-modal banner early in the source so the first Tab reaches it (2.4.3 Focus Order).
  • Visible: each button shows a clear focus indicator (2.4.7 Focus Visible).
  • Not hidden: a banner fixed to the bottom of the screen must not fully cover the focused element (2.4.11 Focus Not Obscured (Minimum)).
  • No trap: focus must never get stuck where it cannot leave (2.1.2 No Keyboard Trap). After a choice, return it somewhere sensible, such as the top of the page.

Readable, even when enlarged

Let people change their mind

People need a way back: a “Cookie settings” link in the same place on every page, for example in the footer (3.2.3 Consistent Navigation). A small floating icon without a name will not do; if you use one, give it an accessible name (4.1.2 Name, Role, Value) and a target of at least 24 by 24 CSS pixels (2.5.8 Target Size (Minimum)).

Checklist

0 of 7 done

Your ticks stay in this browser tab only and are not stored anywhere.

Related WCAG criteria

Tools and patterns for this

Frequently asked questions

Does the cookie banner have to be modal?

No. A non-modal banner is often easier to make accessible. What matters is that it is reachable early and does not hide the focus. If it is modal, focus must stay inside until a choice is made.

Is a close “X” enough?

An “X” needs an accessible name and a large enough target. What closing means for consent is a data protection question to settle separately.

Our banner comes from a third-party tool. Are we still responsible?

The banner is part of your website. Test it like your own pages and ask the provider for fixes or settings.

Sources

How does your website do?

The free check tests your home page in two minutes. The audit decides all 55 criteria, by a person.

Free checkSee pricing

More guides

  • Getting there without a mouse

    Many people use the web without a mouse: with a keyboard, switches, voice control or a screen reader. Here is what has to work for them and how to manage focus properly in modern web apps.

  • EAA compliance check: how to get your website tested for accessibility

    The European Accessibility Act asks for accessible services, not for a particular test. This guide explains what each kind of check can tell you, how an audit works, what ours costs, and what you hold at the end.

  • Contrast that everyone can read

    Pale grey text may look refined, but many people struggle to read it, and on a phone in bright sunlight everybody does. Here are the ratios WCAG 2.2 sets and how to lock them into your design.