WICG Specification

Render HTML into Canvas — natively

A <canvas> is a bitmap you draw on with JavaScript. It can't show HTML. This spec adds three primitives that draw styled, accessible HTML into the canvas without html2canvas or screenshots.

  • Chrome 157+
  • On by default
  • No library
In production — see it running in Graview

Use Chrome 157 or later

HTML-in-Canvas is on by default in Chrome 157+, so there's nothing to turn on. Update Chrome from chrome://settings/help, then reload this page.

On Chromium 147–156 or Brave? Turn on the flag

  1. Paste this URL into your address bar

    Web pages can't link to chrome:// URLs, so you have to paste it. In Brave, brave:// works too.

  2. Set Enable the new drawElement API for Canvas to Enabled
  3. Relaunch the browser

    Click Relaunch at the bottom of the flags page, then reload this site.

In production

See it in action in

Graview builds apps as isometric scenes. Its WebGPU renderer captures every live view with the HTML-in-Canvas API, uploads the capture as a texture, and composites the planes with depth and blur. The DOM underneath stays real, so the views stay focusable, editable, and accessible.

Three Primitives

The spec adds three small pieces of API. Each one solves a separate problem.

1

layoutsubtree

Add this attribute to a <canvas> to opt its children into layout and hit testing. They behave like normal DOM elements but stay invisible until drawn. Chrome 157+ spells it content="drawable" and wants drawable on each drawn child, so set both.

<canvas layoutsubtree content="drawable">
  <div id="content" drawable>
    Laid out, accessible,
    ready to draw.
  </div>
</canvas>
2

drawElementImage()

Draws a child element into the canvas with the current transform applied. Works across 2D, WebGL, and WebGPU contexts.

ctx.drawElementImage(
  element, x, y
);
// Hit testing follows the
// drawn position (Chrome 155+)
3

paint event

Fires when a child element's rendering changes. Clear the canvas and redraw in one callback, once per frame.

canvas.onpaint = (e) => {
  ctx.reset();
  for (const el of e.changedElements) {
    ctx.drawElementImage(el, 0, 0);
  }
};

Why This Matters

Accessibility built in

Drawn elements are the fallback content — the accessibility tree always matches what's on screen.

Real CSS rendering

Fonts, ligatures, RTL, and subpixel text are drawn by the browser, not a polyfill.

No hacks required

Replace html2canvas-style workarounds with a native API that's fast, correct, and privacy-preserving.

2D, WebGL & WebGPU

The same API works in all three canvas contexts, so HTML can be a 3D texture or go through a shader.

Featured Demos

View all demos

Browse all 21 HTML canvas examples across 2D, WebGL, and WebGPU. Each one is complete and forkable.

Featured WebGPU Intermediate

vgpu WebGPU Shader on Live HTML

Shade live HTML with Vercel vgpu: drawElementImage paints a real DOM card into canvas, a WebGPU foil shader warps it on hover, and the same pass snapshots for OG images via vgpu/node. An HTML-in-Canvas demo by En Dash.

featuredvgpuvercelwebgpuhtml-in-canvasdrawElementImagecanvasshaderwgslholographicog-imageendash
WebGL Advanced

Margin Dragon

A watercolour dragon swims through a page of real HTML text that re-flows around it every frame, and its fire burns holes in the live page. By Baked Design Studio.

webgltext-layoutshaderfireillustrationsoundinteractive
WebGL Advanced

Snowfall

A Japanese winter poster where snow settles on real, live HTML type, read from its pixels. Brush it off, write your own word, start a blizzard. By Baked Design Studio.

webglparticlestypographyweathersoundinteractive
WebGL Advanced

Wishing Pond

A real web form at the bottom of a koi pond: type a wish, toss a coin and watch your words sink, while ripples, caustics and weather bend the live HTML. By Baked Design Studio.

webglshaderwaterripplesformsoundinteractive
WebGL Intermediate

Elastic Bulge

Mouse-driven elastic displacement effect: a WebGL2 shader warps laid-out HTML content with a radial bulge and soft drop-shadow that follow the pointer.

webglshaderdisplacementinteractivevisual
WebGL Advanced

3D Room with Live Web Content

A Three.js first-person 3D room where live HTML elements are rendered as textures on surfaces: a monitor dashboard, a styled poster, and a TV playing CSS animations.

demowebglthree-js3dinteractivedom-rendering

Get Started

The HTML-in-Canvas API is on by default in Chrome 157 and later. Chromium 147–156 and Brave have it behind the canvas-draw-element flag. Open a demo to try it.

Coming from html2canvas? See how to render HTML to canvas with the native API — comparison, code, and migration notes.

Frequently Asked Questions

What is the HTML canvas element?

The <canvas> element is an HTML element that gives you a bitmap drawing surface controlled from JavaScript through a 2D, WebGL, or WebGPU context. On its own it cannot render HTML. The WICG HTML-in-Canvas spec adds drawElementImage(), which draws live DOM elements into that surface. Browse the HTML canvas examples for 2D, WebGL, and WebGPU demos.

Can I use HTML inside a canvas element?

Historically, no — <canvas> is a bitmap drawing surface, and any HTML placed inside it is treated as invisible fallback content. The WICG HTML-in-Canvas proposal changes that: its drawElementImage() method renders live DOM elements directly into 2D, WebGL, and WebGPU canvases, and it is on by default in Chrome 157 and later. See it in action in the hello-world demo.

How do I put HTML inside a canvas today?

You have two options: use the native API in Chrome 157+ (older Chromium and Brave need chrome://flags/#canvas-draw-element) and draw elements with drawElementImage(), or use a screenshot-style library like html2canvas that re-implements rendering in JavaScript. See the render HTML to canvas comparison for code and trade-offs, and the browser support guide for setup.