HTMLCanvasElement: content property

Limited availability

This feature is not Baseline because it does not work in some of the most widely-used browsers.

Want more browser support for this feature? Tell us why.

The content property of the HTMLCanvasElement interface indicates whether the <canvas> element is opted into rendering its descendants rather than treating them as fallback content.

Reflects the value of the HTML content attribute.

Value

A string. Possible values are:

drawable

Descendants of the <canvas> element can be rendered on the canvas context using the HTML-in-Canvas API.

fallback

Descendants of the <canvas> element are always treated as fallback content. This is the default value.

Examples

Basic usage

Given this <canvas> element:

html
<canvas id="canvas" width="300" height="300" content="drawable"></canvas>

You can get the value of the content attribute like so:

js
const canvas = document.getElementById("canvas");
console.log(canvas.content); // drawable

And set it like this:

js
canvas.content = "fallback";
console.log(canvas.content); // fallback

Specifications

This feature does not appear to be defined in any specification.

Browser compatibility

See also