Buttons, text and forms can now live in the drawing surface: Chrome 157 makes canvas interactive
After two years of experiments, the HTML-in-Canvas API is in the stable version of Chrome; other browsers have yet to follow.
Google has officially released the HTML-in-Canvas API in Chrome 157, after a trial period as an origin trial, the Chrome developer blog reports. It lets ordinary HTML content be displayed inside a canvas element, in 2D but also in WebGL and WebGPU scenes. According to The Register, two years of experiments preceded the launch, and the API has been proposed for inclusion in the WHATWG HTML Living Standard.
Until now, developers of graphics-heavy web apps had to choose, Google writes. Either they drew text and buttons themselves as pixels, which broke screen readers, find-in-page, copying and translation. Or they floated HTML elements over the canvas, with drift and extra computation on every frame. With the new API the content stays interactive and accessible, even when it is wrapped around a 3D object, for example.
The Register is already seeing exuberant demos appear, such as a dragon winding through the text of an online book, and quotes developer Wes Bos, who expects plenty of silly uses alongside creative ones. The site also fears more intrusive advertising. Other major browsers do not yet support the API, although Microsoft Edge 157, which is built on Chromium, already appears to handle part of it, according to The Register.