Skip to content
easeweb
Search topics

Product photo thumbnails and zoom that need a mouse

A product gallery's thumbnails are images that take only clicks and its zoom follows the mouse, and even as buttons they don't say which photo is shown.

WCAG 2.2
SC 2.1.1ASC 4.1.2A
Required by
Section 508 · EN 301 549 (EU)
Broken <img class="thumb" src="mug-back-small.jpg" alt="">
The accessibility problem illustrated: Motor:How do I see the back of the mug?
01

The problem

Keyboard users can't show any photo but the first or see its detail, and screen reader users aren't told what each thumbnail shows or which photo is on screen

02

Try it

Read the small print on the back of the mug, first with the mouse, then with Tab alone

  • Broken 1: click the last thumbnail and move the mouse over the photo. Then put the mouse aside and press Tab: focus goes straight past the thumbnails to Add to cart.

  • Broken 2: Tab now reaches the thumbnails, and Enter or Space changes the photo. Watch the panel: each one is only “button”, and none is said to be current. The zoom still follows the mouse.

  • Apply a fix. Tab to the last thumbnail and press Enter, then use the control the fix adds. Once the photo is large, the arrow keys move it.

Broken Can you fix this?

Enamel mug

$24

Screen reader says:

(Tab into the gallery, or click a thumbnail)

A recreated demo. The broken version is intentionally inaccessible.

03

The fix

Let the keyboard change and enlarge the photo

Before

Thumbnails and zoom that take only a mouse

<div class="gallery">  <div class="photo-frame">    <img class="photo" src="mug-front.jpg" alt="Front of the mug">  </div>  <div class="thumbs">    <img class="thumb is-current" src="mug-front-small.jpg" alt="" data-photo="mug-front.jpg" data-alt="Front of the mug">    <img class="thumb" src="mug-side-small.jpg" alt="" data-photo="mug-side.jpg" data-alt="Side of the mug">    <img class="thumb" src="mug-back-small.jpg" alt="" data-photo="mug-back.jpg" data-alt="Back of the mug">  </div></div>
What is wrong5 points
  • The thumbnails are images that respond only to click, so they have no Tab stop and the keyboard can't show another photo.
  • They have no role, and their alt text is empty.
  • The current thumbnail is marked by the is-current class, which only draws its border.
  • The zoom starts only from mousemove, so the keyboard can't reach the detail it shows.
  • A new photo replaces the old one without a word to a screen reader.
After

A Zoom button over a box that scrolls

<div class="gallery">  <button type="button" class="zoom">Zoom in</button>  <div class="photo-frame" role="region" aria-label="Zoomed photo">    <img class="photo" src="mug-front.jpg" alt="Front of the mug">  </div>  <p class="photo-count" aria-live="polite">Photo 1 of 3: Front of the mug</p>  <div class="thumbs">    <button type="button" class="thumb" aria-current="true" data-photo="mug-front.jpg">      <img src="mug-front-small.jpg" alt="Front of the mug">    </button>    <button type="button" class="thumb" data-photo="mug-side.jpg">      <img src="mug-side-small.jpg" alt="Side of the mug">    </button>    <button type="button" class="thumb" data-photo="mug-back.jpg">      <img src="mug-back-small.jpg" alt="Back of the mug">    </button>  </div></div>
How it is fixed7 steps
  1. Make each thumbnail a real button with its image inside. Tab reaches it and Enter and Space press it, with no key handling to write.
  2. Write each thumbnail's alt text to say which photo it shows. With the image as the button's only content, that text is the button's name.
  3. In the click handler, set aria-current="true" on the current thumbnail and take it off the others, so a screen reader says "current" on it.
  4. Draw the border from [aria-current='true'], so the look and the announcement can't disagree.
  5. As good practice, say which photo is shown in a polite live region, so a press is heard without moving focus.
  6. Add a Zoom in button. It makes the photo three times as wide in a box that scrolls, and gives that box a Tab stop, so the arrow keys move around the photo. Keep the button ahead of the box, so Tab meets it first.
  7. Leave the zoom that follows the mouse in place as a shortcut, and switch it off while the button has the photo zoomed.

This fixes both Befores and passes 2.1.1 and 4.1.2. The zoomed photo needs a large enough file behind it to keep its detail sharp at three times the width.

04

Design ideas

A gallery doesn’t have to be a row of small pictures

Six ways to draw the mug’s gallery. Try each with the mouse, then put the mouse aside and press Tab: four show every photo from the keyboard, and two only with a mouse.

In the design file

  • Show the current photo’s mark as a shape, such as a bar, a ring or a filled pill, not only a colour or a dimmed look.
  • Write what each thumbnail shows beside it, such as “Back of the mug”, since it becomes the name a screen reader reads.
  • Beside any magnifier that follows the pointer, draw a Zoom button, an Enlarge button or a link for someone with no mouse.
  • Draw the focus ring on a thumbnail, with room round it so it isn’t cut off.
  • Draw arrows that appear on hover also as they show on keyboard focus and on a touch screen, or keep them showing.

Passes

  • Every photo on the page No thumbnails at all: the photos sit in the page, one large and two beside each other, so there is nothing to switch and no current photo to mark. Each is a link to its large file, which also gives the keyboard its way to the detail. It costs page length, so the Add to cart button needs to stay in view beside them.
  • Words in pills Front, Side and Back in pills under the photo, so nobody has to tell small pictures apart, and the word on each is the name a screen reader reads. The current pill fills with navy, white on #2d3a55 at 11.36:1, a solid fill against the others’ outline, not just a new hue.
  • Arrows round a count No row of pictures to fit on a phone: two 36px round arrows either side of “2 / 3”. The count says in plain figures which photo is shown, and a polite live region reads it when it changes. Nobody can jump straight to a given photo, only step to it, so keep it to a few.
  • A rail with a bar on the current one Thumbnails down the side of the photo, the current one with a 4px navy bar along its left edge, at 10.22:1 on the thumbnail’s #f1f3f6 tint. The others stay at full strength, so they can still be told apart. The rail folds under the photo on a phone.

Fails

  • Photo changes as the mouse rests on a thumbnailWCAG 2.1.1 Quick and effortless with a mouse: there is nothing to click. But there is nothing to press either, so Tab passes the thumbnails by and the keyboard stays on the first photo.
  • Arrows that come out on hoverWCAG 2.1.1 A clean photo until the mouse arrives. The arrows are real buttons, but while they are hidden they take no focus, so Tab passes them by and the keyboard never sees another photo. Show them on focus too, or keep them showing.
05

Verify the fix

4 checks, no mouse.

Test with: Keyboard, Screen reader, Forced colors

0 of 4 checked

Record the OS, browser and assistive-technology versions, the build, the date, and the actual result of each step. Repeat after the gallery, its library or its theme changes.

How screen readers handle aria-current="page"

Limits

This is a starting pattern, not a guarantee for every application. It covers how the thumbnails and the zoom are reached and what the thumbnails say. A gallery built as slides with arrows and dots is covered in carousels that keyboard and screen reader users can't use. A lightbox has its own needs for focus and closing: see modals that leave keyboard focus behind them. A photo viewer that turns or zooms by dragging, pinching or tilting is in pinch, drag and tilt gestures with no button. What each photo's alt text should say is a matter for the photo: this guide only asks that a thumbnail's alt text tells the photos apart, and that the large photo's stays in step when it changes.

This is a recreated teaching example, not a finding about a named client. The code is a starting pattern: test it in your own product. No completed assistive-technology test is claimed here.

EaseWeb service

Fixed it? Keep it from coming back.

I turn guides like this one into rules your coding agents follow and checks your CI runs. Then I retest by hand with a keyboard and screen readers, periodically.

See the service