Accessible Clickable Card options
Cards can be challenging to make accessible. Designers often want the entire card to be clickable, but this can create accessibility issues.
The examples below show different ways to make cards interactive.
Each card contains a container, an image, an <h3> heading and a short paragraph.
Method 1: Just the default – users click the link in the heading
No extra markup or scripting. The only interactive element is the link inside the heading.
Laughing kookaburra
Known for its distinctive call, this large kingfisher is native to eastern Australia.
Accessibility features
- Only one interactive element on the card, with a clear accessible name.
- Standard keyboard behaviour: Tab to focus, Enter to activate.
- Native link behaviours work automatically, including opening in a new tab, copying the link address and bookmarking.
- Works even if CSS or JavaScript fails to load.
Possible issues
- The clickable target is small, limited to the heading text.
- Users may click the image or paragraph expecting to navigate, but nothing happens.
- On touch devices, users may expect a larger clickable area.
HTML
<div class="card">
<img src="https://placehold.co/300x120" alt="">
<h3><a href="#">Laughing kookaburra</a></h3>
<p>Known for its distinctive call, this large kingfisher is native to eastern Australia.</p>
</div>
Recommended: The simplest and most reliable option. Uses standard HTML and needs no JavaScript. The main downside is the small clickable area.
Method 2: A single link with no separate heading link
The entire card is wrapped in a single link. The heading is plain text, not a separate link.
Tasmanian devil
The world's largest carnivorous marsupial, now found in the wild only on the island of Tasmania.
Accessibility features
- Valid HTML with no nested interactive elements and only one tab stop.
- Large click/tap target with standard link behaviour.
- No JavaScript required.
Possible issues
- Best suited to cards with a single destination. Additional links or buttons must sit outside the main link.
- The link may have a long accessible name, as it can include the image alt text, heading and paragraph.
- Screen reader users can find the link in a links list, but its name may contain more than just the heading.
HTML
<a class="card-single-link" href="#">
<div class="card">
<img src="https://placehold.co/300x120" alt="">
<h3>Tasmanian devil</h3>
<p>The world's largest carnivorous marsupial, now found in the wild only on the island of Tasmania.</p>
</div>
</a>
Recommended: A good option for cards with a single destination. Valid HTML, one tab stop, a large click target and standard link behaviour, with no JavaScript.
Method 3: CSS used to expand the link to cover the card
Only the heading contains a link. CSS uses an absolutely positioned ::after pseudo-element to extend the clickable area across the whole card. This is sometimes called the "stretched link" pattern.
Accessibility features
- Only one link exists in the markup, with an accessible name based on the heading text.
- Standard link behaviour, including opening in a new tab and copying the link address.
- Large clickable area without JavaScript.
Possible issues
- The card needs
position: relative, and the link's::afterpseudo-element needsposition: absoluteandinset: 0. Changes to the CSS may break the clickable area. - Other interactive elements, such as links or buttons, may be covered by the invisible layer. They may need a higher
z-indexto remain clickable. - Users may be unable to select text inside the card with a mouse because the invisible layer intercepts mouse interactions.
HTML
<div class="card card-css-expand">
<img src="https://placehold.co/300x120" alt="">
<h3><a href="#">Emu</a></h3>
<p>The emu is the second-tallest living bird after its ratite relative, the ostrich.</p>
</div>
Recommended: A good option when you want to keep the heading as the link while making the whole card clickable. No JavaScript required, but care is needed when adding other interactive elements.
Method 4: A non-link element with a click handler (fake button/link)
The card uses JavaScript to behave like a link, without using a real <a> element. Additional code is needed to support keyboard and screen reader users.
Accessibility features
- Can be made accessible to keyboard and screen reader users with
role="link",tabindex="0", a clear accessible name and keyboard support. - Large clickable area with control over styling and behaviour.
Possible issues
- Native link features, such as opening in a new tab, copying the link address and middle-clicking, are not available by default.
- The accessible name must be checked to make sure it is clear and not too long.
- Search engines and other tools may not discover the destination because there is no real link.
- Keyboard support must be added manually. A link should activate with Enter, while a button should activate with Enter or Space.
- If JavaScript fails to load, the card will not work.
- Requires more code and testing than a standard HTML link.
HTML
<div class="card card-fake-button" id="js-card-2" tabindex="0" role="link">
<img src="https://placehold.co/300x120" alt="">
<h3>Quokka</h3>
<p>A small wallaby often described as "the world's happiest animal" because of its friendly expression.</p>
</div>
Do not use: This approach requires extra code and testing, loses native link features and depends on JavaScript. Use a real <a href> instead.
Method 5: JavaScript finds the link and makes the whole card clickable
The heading contains a real link. JavaScript listens for clicks anywhere on the card and follows the heading link, unless the user clicks another interactive element.
Accessibility features
- Only one link in the markup. The card itself is not focusable, so there are no extra tab stops.
- Keyboard users can focus and activate the link normally.
- If JavaScript fails to load, the heading link still works.
- The script can ignore other interactive elements and text selection.
Possible issues
- JavaScript needs to handle edge cases, such as text selection, middle-clicks and clicks with modifier keys.
- Middle-clicking or using Ctrl/Cmd-click on the card does not automatically open the link in a new tab. These actions still work on the actual link.
- Requires additional JavaScript and testing.
HTML
<div class="card card-js">
<img src="https://placehold.co/300x120" alt="">
<h3><a href="#">Wombat</a></h3>
<p>This large, stocky marsupial is found in Australia and on scattered nearby islands.</p>
</div>
JavaScript
document.querySelectorAll('.card-js').forEach(function (card) {
var link = card.querySelector('h3 a');
if (!link) return;
card.addEventListener('click', function (event) {
// Let clicks on real interactive elements behave normally
if (event.target.closest('a, button, input, select, textarea')) return;
// Don't navigate if the user is selecting text
var selection = window.getSelection();
if (selection && selection.toString().length > 0) return;
link.click();
});
});
Recommended: A good option when JavaScript is needed. It extends the clickable area without replacing the real link. Standard keyboard and screen reader behaviour is preserved, and the link still works if JavaScript fails.