Skip to main content
Back

Chrome's HTML-in-Canvas API Ends 20 Years of Web Graphics Tradeoffs

Chrome's HTML-in-Canvas API enters origin trial, letting live DOM elements render directly inside WebGL and WebGPU textures with full accessibility preserved

  • DOM meets GPU: Chrome's HTML-in-Canvas API lets live DOM elements render directly inside WebGL and WebGPU textures, preserving full interactivity.
  • Origin trial live: Available now in Chrome 148-150 via chrome://flags/#canvas-draw-element or the official origin trial registration.
  • Accessibility included: DOM elements remain real DOM nodes inside the canvas, so screen readers, find-in-page, and text selection all work automatically.
  • Kills the old hacks: Replaces brittle libraries like html2canvas that took screenshots of the DOM, breaking on CORS, video, SVG, and complex CSS.
  • Three.js and PlayCanvas integrations already available, with Three.js PR #31233 adding an HTMLTexture class for drop-in use.
  • Key use cases: Game HUDs inside WebGL scenes, data viz dashboards with real form controls, and 3D surfaces with fully interactive HTML textures.

For roughly two decades, web developers building 3D or canvas-heavy experiences have faced a brutal fork in the road: use the DOM for rich, accessible, interactive UI, or use Canvas for fast GPU-accelerated graphics. Pick one. The other side of that fork just got paved over. At Google I/O 2026, Chrome engineer Thomas Nattestad unveiled the HTML-in-Canvas API, a new web platform feature that lets developers render HTML elements directly into canvas, WebGL, and WebGPU contexts while preserving accessibility and interactivity.

A hack that accumulated tens of thousands of GitHub stars

Before this API, the workaround was libraries like html2canvas and dom-to-image. These libraries accumulated tens of thousands of GitHub stars not because they were good solutions, but because they were the only solutions. They work by taking screenshots of the DOM, reimplementing CSS layout and paint in JavaScript, then dumping the result to an image.

The output is a frozen snapshot, not live content. The failure modes are well-documented and painful: external images fail due to CORS restrictions, video and SVG elements render blank, and complex UIs can take 20 seconds or more to capture. These were not bugs in the libraries. They were fundamental limitations of the approach, since the browser's layout engine is simply not exposed to JavaScript.

Canvas content has always been opaque to assistive technology. WCAG compliance in any canvas-heavy UI required duplicating content in hidden DOM elements, which is fragile and expensive to maintain. The HTML-in-Canvas API eliminates that entirely.

What the API actually does

The new HTML-in-Canvas API lets you draw live DOM elements directly into a 2D canvas, a WebGL texture, or a WebGPU texture, while preserving accessibility, find-in-page, translation, dark mode, autofill, browser extensions, and DevTools inspection. The DOM elements remain real DOM elements, they just render inside the canvas.

The API surface is intentionally small. It introduces three core primitives:

  • layoutsubtree attribute -- Add this to your <canvas> element. It tells the browser to lay out child elements normally but suppress their visual output to the page. They exist in the DOM, participate in layout, and respond to events.
  • drawElementImage() / texElementImage2D() -- These push the element's current visual state into the canvas. The 2D variant draws it directly; the WebGL variant uploads it as a GPU texture. WebGPU gets copyElementImageToTexture().
  • The paint event -- Fires on the canvas whenever a child element's rendering changes, enabling efficient, event-driven redraws with no polling.

Here is what a minimal interactive HUD looks like:

<canvas layoutsubtree id="scene">
  <div id="hud">
    <h2>Player HUD</h2>
    <input type="range" min="0" max="100" value="75" />
  </div>
</canvas>
<script>
const canvas = document.getElementById('scene');
const ctx = canvas.getContext('2d');
canvas.addEventListener('paint', (e) => {
  for (const el of e.changedElements) {
    ctx.drawElementImage(el, 0, 0);
  }
});
</script>

That is a real, interactive input slider rendered inside a canvas, with zero image-capture tricks and zero accessibility loss.

For 3D rendering, you can upload a DOM element directly as a WebGL or WebGPU texture. This is the most efficient path, as it avoids a CPU round-trip by going directly from the browser compositor to GPU texture memory.

Where it shines

Three use cases stand out as immediately compelling:

  • Game UIs and HUDs. HTML-in-Canvas collapses the old approach into one: write your HUD in HTML and CSS, render it inside the WebGL scene, and keep keyboard navigation and screen reader support.
  • Data visualization dashboards. Chart axes, filter inputs, legends, and tooltips can now be real HTML form elements rendered into the visualization canvas, sharing one coordinate system. No more z-index wars between overlaid DOM elements and canvas charts.
  • 3D surfaces with live content. A form rendered as a texture on a 3D surface still works with screen readers. Buttons on a spinning cube still respond to clicks. Text inputs on a curved menu still show blinking cursors.

Framework support is already here

The ecosystem moved fast. With the HTML-in-Canvas API, you can integrate real DOM elements directly into a canvas with WebGL and WebGPU to build an immersive 3D experience that is searchable, accessible, and natively translatable. Combine this with view transitions, like element-scoped (available now in Chrome 147) and two-phase transitions (currently in testing), to create layered UI motion and animate intermediate states without blocking page interactivity.

Three.js and PlayCanvas integrations are already available. The Three.js PR #31233 by mrdoob adds an HTMLTexture class that handles DOM-to-texture synchronization automatically, so you can drop it into existing Three.js scenes with minimal changes.

The accessibility argument is not an afterthought

With HTML-in-Canvas, the DOM elements are the rendered content. The accessibility tree is automatically correct. Find-in-page works. Text is selectable. You get compliance without parallel structure. For teams building canvas-heavy apps that need to meet WCAG standards, this alone is a significant architectural simplification.

This is one of the most consequential changes to the web platform in years, and it shipped behind a one-paragraph bullet point on the dev keynote recap. The community has noticed: multiple developers have called it the most important non-AI announcement from Google I/O 2026, noting that HTML-in-Canvas felt different from the AI-heavy announcements, like one of those foundational platform improvements that developers may quietly depend on for years.

How to try it today

The API is currently available as an Origin Trial in Chrome 148-150. Developers can opt in via the origin trial token or enable chrome://flags/#canvas-draw-element. For production sites, you can register your origin at developer.chrome.com/origintrials to serve real users during the trial period.

The WICG specification is open for feedback on GitHub. This is the phase where developer input actually shapes the final API surface, so if you hit edge cases, the working group wants to hear about them now. The API is not yet ready for production at scale, but it is absolutely ready to prototype.