The CanvasRenderingContext2D.canvas property is a read-only reference to the HTMLCanvasElement object that is associated with the context. It might be null if there is no association with an <canvas> element.

Syntax

ctx.canvas;

Examples

Given this <canvas> element:

<canvas id="canvas"></canvas>

You can get a reference to the canvas element within the CanvasRenderingContext2D by using the canvas property:

var canvas = document.getElementById('canvas');
var ctx = canvas.getContext('2d');
ctx.canvas // HTMLCanvasElement

Specifications

Specification Status Comment
HTML Living Standard
The definition of 'CanvasRenderingContext2D.canvas' in that specification.
Living Standard  

Browser compatibility

FeatureChromeEdgeFirefoxInternet ExplorerOperaSafari
Basic support Yes Yes Yes Yes Yes Yes
FeatureAndroid webviewChrome for AndroidEdge mobileFirefox for AndroidOpera AndroidiOS SafariSamsung Internet
Basic support Yes Yes Yes Yes Yes Yes ?

See also

Document Tags and Contributors

 Contributors to this page: fscholz, nmve, erikadoyle
 Last updated by: fscholz,