Anyone who has built a chart, a game menu or a design tool on <canvas> knows the pain: text is drawn with fillText(), there is no layout, no line wrapping, no form inputs, and screen readers see nothing unless you maintain a hidden copy of the content in the DOM. Chrome 157, scheduled for stable release on 3 November 2026, ships HTML-in-Canvas, which lets you draw real, laid-out, interactive HTML elements into a canvas. Here is how the API works, a minimal example you can run, and where its limits are.
What HTML-in-Canvas actually is
The feature came out of a WICG proposal and ran as an origin trial before shipping. The Chrome 157 release notes describe it as primitives for "canvas layout, drawing, DOM-to-canvas sync events, and geometry updates for canvas-to-DOM sync". In plain terms, you get five building blocks:
A
contentattribute on<canvas>. Set it todrawableand the canvas's children are laid out like normal DOM instead of being treated as fallback content.A
drawableattribute on child elements. Only elements marked this way can be drawn.A
paintevent on the canvas, fired when a drawable child would render differently, plusrequestPaint()for apps that redraw every frame (think of it as the canvas version ofrequestAnimationFrame()).drawElementImage()on the 2D context, withtexElementSubImage2D()for WebGL anddrawElementImageToTexture()for WebGPU.updateElementGeometry(), which tells the browser where an element ended up on screen so hit testing and accessibility line up with what you drew.
A minimal example you can run
This is the basic pattern from the WICG explainer: a form inside a canvas, drawn 100 pixels from the left edge.
<canvas style="width: 400px; height: 200px;" content="drawable">
<form drawable>
<label for="name">name:</label>
<input id="name">
</form>
</canvas>
<script>
const canvas = document.querySelector('canvas');
const form = document.querySelector('canvas form');
const ctx = canvas.getContext('2d');
canvas.onpaint = () => {
ctx.reset();
ctx.drawElementImage(form, 100, 0);
};
// Match the canvas grid to the device pixel ratio
new ResizeObserver((entries) => {
canvas.width = entries[0].devicePixelContentBoxSize[0].inlineSize;
canvas.height = entries[0].devicePixelContentBoxSize[0].blockSize;
}).observe(canvas, { box: 'device-pixel-content-box' });
</script>
Three things are worth noticing. First, you draw inside the paint handler, because that is when the browser has a fresh snapshot of the element. Calls outside it reuse the previous snapshot. Second, the input is real: it takes focus, shows a caret and accepts typing, and the caret is drawn into the canvas. Third, in a 2D context drawElementImage() updates the element's geometry for you, so clicks land on the input where you drew it.
The explainer also notes that drawElementImage() throws if the element lacks the drawable attribute, if no snapshot exists yet, or if the element sits inside another canvas. If your first frame throws, that is usually why.
Feature detection
Chrome's announcement suggests checking whether the attribute "sticks":
function supportsHtmlInCanvas() {
if (typeof document === 'undefined') return false;
const canvas = document.createElement('canvas');
canvas.setAttribute('content', 'drawable');
return canvas.content === 'drawable';
}
If this returns false, keep your existing approach, whether that is an HTML overlay positioned above the canvas or plain fillText().
2D vs WebGL and WebGPU
In 2D, the browser knows where you drew the element, so geometry syncs automatically. You can turn that off by passing { preserveElementGeometry: true } as an option.
In 3D, the browser can't know how your shader mapped a texture onto the scene, so you must call updateElementGeometry() yourself with a canvasTransform (a DOMMatrix). The Chrome team's write-up points out that this avoids the per-frame style.transform writes that overlay techniques need. It also lists early library support: an experimental THREE.HTMLTexture in Three.js, an HtmlTexture in Babylon.js, and an HTMLSource in PixiJS from v8.19.0. Those libraries are maintained by their own communities, not by Google, so check their docs for the current state.
Accessibility, privacy and what isn't drawn
This is the part I like most. Drawable content stays in the accessibility tree like any other DOM, unless you hide it with aria-hidden or inert. Once geometry is updated, assistive tech knows where each element is. Compare that with fillText(), where you had to keep a parallel invisible DOM in sync by hand. If you have been following accessibility deadlines, such as the SEBI accessibility checklist for financial platforms, this is a real improvement for canvas-heavy interfaces.
The flip side is privacy. Because a page can read pixels back from a canvas, the browser leaves out anything that would leak information JavaScript can't already see. According to the explainer, that includes:
Cross-origin content in iframes, images and
url()referencesVisited-link styling, system colours and theme preferences
Spelling and grammar markers, and pending autofill values
Subpixel text anti-aliasing, video captions and controls, and IME pop-ups
So if a cross-origin image vanishes from your drawing, it is behaving as designed.
One more gotcha: drawable children start out not hit-testable. In 2D that fixes itself when you draw them. In 3D, nothing is clickable until you call updateElementGeometry().
When to reach for it, and when not to
Good fits:
Charts with wrapped, multi-line labels and legends that you want screen readers to read.
Editors and design tools that render UI panels inside a canvas workspace.
Games and 3D scenes with menus, terminals or readable in-world text.
Export tools: Chrome notes that
toBlob(),toDataURL()andcaptureStream()include the drawn HTML.
Poor fits: anything that works fine as normal DOM. If you only want a fancy transition, CSS is still the simpler tool. Our guide to view transitions in React 19.3 covers a lot of what people used to fake in canvas.
And remember browser support. As of early November 2026, Chrome's announcement covers Chrome only and doesn't mention other engines shipping it, so feature-detect and keep a fallback. If you are tidying up loading behaviour while you are at it, the change in Chrome 156 that lets you retry failed dynamic imports pairs nicely with lazy-loading a heavy canvas feature only where it is supported.
What to do this week
If you maintain a canvas UI, pick one piece of text you currently draw with fillText(), such as a chart legend, and rebuild it as a drawable element behind the feature check above. You will find out quickly whether the paint-event model fits your render loop, and you will get accessibility for that piece more or less for free.



