A four-year-old taps a letter on a tablet and hears a cheerful sound. Another four-year-old, using a screen reader, gets silence. Rhiana Heppenstall puts it plainly: canvas elements "are not accessible to keyboards and screen readers. They are treated as blank images."
Heppenstall, an accessibility lead at 3P Learning, wrote up how her team fixed that for the Readingeggs reading activities on day 2 of the HTMHell Advent Calendar. The activities moved from Flash to canvas when Flash declined, especially for iOS apps, in 2010. Rewriting thousands of them wasn't realistic, and an alt-text-style description couldn't cover activities this detailed. Fallback HTML was the lower-risk option, and it could ship incrementally without interrupting anyone's learning.
A second interface behind the drawing
The <canvas> element is designed to carry fallback HTML for when it doesn't load. Heppenstall's team turned that fallback into a real interface: headings, text and buttons a screen reader can read out. JavaScript links each interactive HTML element to the image or text drawn on the canvas, so a keyboard user gets interactivity and a visible focus state. She credits a canvas demo by Paul J. Adam as the inspiration.
One detail could save you a day of debugging. The documentation said to put the fallback inside the <canvas>, but the team found that wasn't compatible with Safari. Placing the HTML after the element fixed it:
<canvas>
</canvas>
<h1>Activity Title</h1>
<p>Instructions</p>
<button>Press me!</button>
Heppenstall adds that Chrome is working on exposing the HTML inside a canvas to the browser through a content="drawable" attribute, which she says isn't standard practice yet and has limited browser support.
One letter grid, marked up
The worked example is a letter grid where the child finds every "i". The top bar has no words, because preschoolers may not read yet, so every icon needs a spoken equivalent that means something. Reading out "2/2" or "speaker icon" tells a child nothing. The team settled on this:
<h1>Letter grid</h1>
<header aria-label="Top Bar">
<span>Round 2 of 2</span>
<span aria-live="polite">2 lives remaining</span>
<button>Play Instructions</button>
</header>
The <h1> names the activity, whose title is otherwise visible only on the instructions page before it. The lives counter carries aria-live="polite" because a life can be lost at any moment. The replay button is a real <button>, and when it has keyboard focus a custom outline appears around its canvas counterpart, much like a native button's focus ring.
The grid itself is a list of buttons inside a labelled section:
<section aria-label="Activity Content">
<ul aria-label="Click on 'i'" aria-description="Find and select all the letters matching 'i'">
...
</ul>
</section>
<li><button disabled="true">i</button></li>
<li><button>o</button></li>
The list tells a screen reader user how many items there are, and keyboard users can Tab between the letters. A correct letter changes colour and gets the disabled attribute, so the keyboard state matches what a mouse user sees. The aria-description holds instructions more specific than the audio prompt, which a child who is also hearing impaired can read on a braille display.
A wrong answer triggers a hidden message (Heppenstall notes role="status" would also work):
<div aria-live="polite" aria-atomic="true">"l" is incorrect. Try again.</div>
The progress tracker, drawn as stars, became one line of text instead of images a user would have to count one by one:
<span aria-description="Scoreboard">2 out of 6 found.</span>
Where the team made judgement calls
This section is the best part of the post, because it doesn't pretend the answers are obvious. The team didn't write "Lower case i" into the labels, because VoiceOver and the other screen readers they tested have settings that describe each character. The user's own tool already handles it, which is the right place for it.
In two-dimensional grids, some pages support arrow keys as well as Tab. Heppenstall flags the risk herself: custom key handling may not be intuitive and may confuse screen readers.
On forms, Heppenstall writes that the WCAG guidelines recommend <form> controls with <legend>, <input> and a submit <button> for question-and-answer content. The team kept plain buttons that submit when pressed, with screen reader instructions saying so, because that matches the visual experience for children as young as four. She describes it as possibly a technical violation but not one in spirit. I agree. An extra submit step that sighted children never see would make the accessible version a harder activity, and announcing the behaviour up front is what makes the choice defensible.
My verdict, and what to take to your next canvas PR
Heppenstall says that if they built it today, the team might use the drawable approach or skip canvas entirely. For canvas interfaces that already exist, though, fallback HTML is a fix you can ship one screen at a time. The gap is testing, which so far has mostly been VoiceOver on Safari, since many students use iPads. The team's stated next step is user testing with native screen reader users, ideally young ones, across a variety of screen readers. Until that happens, treat the markup as a strong first draft, not a finished answer.
If you own a canvas UI:
- Mirror every drawn control with a real
<button>or link, and tie its keyboard focus to a visible outline on the canvas. - Check where the fallback sits in Safari. Heppenstall's team had to move it after the
<canvas>. - Put
aria-live="polite"on state that can change at any moment, like lives and wrong answers. - Add
disabledto anything that can't be pressed again, so keyboard and mouse users see the same state. - Test with people who use screen readers every day, not only your own VoiceOver session.
Top comments (1)
The mirrored controls are where I'd test hardest. If they end up as divs with role="button", they also need tabIndex and a key handler for Enter and Space, and that's easy to miss when the canvas is doing the visual work. A native button element gets both without extra code. Putting the mouse away and running one activity with Tab, Enter, Space and Escape catches most of it.