HTML-in-Canvas ships and could make the web a lot more creative...and a lot stupider
After two years of experimentation, the Chrome team shipped the HTML-in-Canvas API with Chrome 157. With it comes a new vision of how Web pages could be designed, for better or worse, allowing richer, more interactive elements but also more opportunities for annoying ads.
“Previously, when creating visually demanding web apps, you had to choose between standard HTML elements and raw canvas contexts,” enthused one Google DevRel in a tutorial . “HTML-in-Canvas eliminates these trade-offs.”
The Web API has been submitted for inclusion in the WHATWG HTML Living Standard , the ever-updating standard formerly known as HTML5 – for all the technologies that officially make up HTML (including Canvas itself).
A Web API for the browser’s rendering engine
Originally developed by Apple and standardized in 2014, the canvas tag is an HTML element that offers a space to render fluid graphics via JavaScript drawing commands. It creates a dedicated grid on screen, within which JavaScript can use a set of Canvas methods to draw lines, curves, text, gradients, and images. Or, the user’s GPU, via WebGL or WebGPU, can use the canvas to render 3D images and other custom effects.
The downside of Canvas is that the regular HTML controls didn’t work inside the canvas itself. Formatting any text had to be done by hand. Interactivity was out, as were accessibility aids.
Primarily developed by the Google Chromium team, HTML-in-Canvas allows JavaScript to place HTML commands within the canvas element, thanks to an attribute option within Canvas. If the canvas tag includes a content attribute of "drawable," the browser’s rendering engine prepares the HTML content inside the box so JavaScript can render it.
While fully supported by Chrome and Chrome Android beginning with release 157, none of the other major browsers support the API yet (Microsoft Edge 157 – which is made of Chromium – unofficially appears to support at least some HTML-in-Canvas actions as well).
The Web’s about to get lit




Comments
No comments yet. Be the first to share your thoughts.