Skip to content
easeweb
Search topics

Star ratings that keyboards and screen readers skip

A review form draws five stars that fill up to the one you click, built from spans with a click handler or from radio buttons hidden with display: none, so Tab never reaches them, a screen reader hears no rating, and the choice exists only as filled stars.

WCAG 2.2
SC 2.1.1ASC 4.1.2ASC 1.3.1A
Required by
Section 508 · EN 301 549 (EU)
Broken <span class="star" onclick="rate(4)">
The accessibility problem illustrated: Motor:How do I choose the stars?
01

The problem

Keyboard and switch users can't choose a rating, and screen reader users hear neither the stars nor which one is chosen, so they can't rate a product or check the rating they gave.

02

Try it

Click a star, then put the mouse aside: press Tab to reach the stars and give 4 stars with the arrow keys.

With a mouse, both versions fill the stars. The panel shows what a screen reader hears as focus moves and the choice changes: is a star ever announced, or which one is chosen? In Broken 2, the stars are real radio buttons, removed with display: none.

Broken Can you fix this?

Your rating

Screen reader says:

(Tab through the form)

A recreated demo. The broken version is intentionally inaccessible.

03

The fix

Build the stars as one radio group named by its question, with each star named by its value.

  1. 1Build the stars on radio buttons, or on role="radio" with aria-checked, in one group named by the question.
  2. 2Name each star by its value, "1 star" to "5 stars".
  3. 3Draw the filled stars and the focus ring from the checked and focus states.
Before

Five spans with onclick

<form action="/reviews" method="post">  <p class="question">Your rating</p>  <div class="stars">    <span class="star" onclick="rate(1)"></span>    <span class="star" onclick="rate(2)"></span>    <span class="star" onclick="rate(3)"></span>    <span class="star" onclick="rate(4)"></span>    <span class="star" onclick="rate(5)"></span>  </div>  <input type="hidden" name="rating">  …  <button type="submit">Post review</button></form>
After

Radio buttons over the drawn stars

<form action="/reviews" method="post">  <fieldset class="stars">    <legend class="question">Your rating</legend>    <label class="star">      <input type="radio" name="rating" value="1">      <span class="visually-hidden">1 star</span>    </label>    <label class="star">      <input type="radio" name="rating" value="2">      <span class="visually-hidden">2 stars</span>    </label>    <label class="star">      <input type="radio" name="rating" value="3">      <span class="visually-hidden">3 stars</span>    </label>    <label class="star">      <input type="radio" name="rating" value="4">      <span class="visually-hidden">4 stars</span>    </label>    <label class="star">      <input type="radio" name="rating" value="5">      <span class="visually-hidden">5 stars</span>    </label>  </fieldset>  …  <button type="submit">Post review</button></form>

Why this fix: Use native HTML first

Fixing this with an AI coding assistant? Get this guide as Markdown, or get every guide in your coding agent.

04

Design ideas

A rating can be stars, numbers or faces, as long as a key can choose it.

Four ways to draw a rating. Click them, then put the mouse aside and try each with Tab and the arrow keys: three pass, and one gives the mouse a half star that no key can give.

In the design file

  • Mark the stars in the design file as one question with five choices, a radio group, so they are built on radio buttons.
  • Write the question above the stars, and a name for each star, “1 star” to “5 stars”, which a screen reader reads out.
  • Draw a star with its focus ring, as it looks when reached with Tab and moved with the arrow keys.
  • Draw the rating before anything is chosen, and say whether it can be cleared once chosen.

Passes

  • Your rating
    Numbered circles, the ends named Five 40px circles numbered 1 to 5, with “Poor” and “Excellent” under the ends, as survey tools draw them. The number is the rating, so it reads at a glance and in greyscale; the chosen circle fills with #1a1a1a ink, 17.40:1 on white.
  • Your rating Choose a face
    Faces, the chosen one named Five faces from very unhappy to very happy, each named for what it means, and the chosen one’s word written under the row, so nobody has to read a face. The chosen face takes an amber tint and a #b45309 ring, 5.02:1 on white.
  • Your rating
    Stars with a quiet Clear A rating that may stay empty needs a way back, since a chosen star can’t be unchosen by a key. “Clear”, underlined in #4b5563, 7.56:1, appears after the stars once one is chosen, and empties them for the mouse and the keyboard alike.

Fails

  • Your rating
    Half stars set by where the pointer landsWCAG 2.1.1 A click on the left half of the fourth star gives 3.5, but Tab and the arrow keys move only between the five whole stars, so no key gives a half. Draw ten choices if halves matter, or keep whole stars.
05

Verify the fix

5 checks.

Test with: Keyboard, Screen reader, Mouse, Forced colors, Touch

0 of 5 checked

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

Limits

This is a starting pattern, not a guarantee for every application. The CSS is a sketch: check the size of the stars, their contrast and the focus ring against your own palette. Stars told apart only by colour, such as a grey star and a yellow star of the same shape, are a different failure, left to the topic on colour alone, whose guide is in progress. A group of radio buttons whose question isn't tied to them is covered in radio buttons and checkboxes without a group name. Test the whole review form with a keyboard, a screen reader and a phone.

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.

Keep this fixed as your code changes.

Turn guides like this into rules your coding agents and CI follow, then have the result retested with a keyboard and screen readers.

How retests work