The CanvasRenderingContext2D.canvas property is a read-only reference to the HTMLCanvasElement object that is associated with a given context. It might be null if there is no associated <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

Update compatibility data on GitHub
DesktopMobile
ChromeEdgeFirefoxInternet ExplorerOperaSafariAndroid webviewChrome for AndroidEdge MobileFirefox for AndroidOpera for AndroidiOS SafariSamsung Internet
Basic supportChrome Full support YesEdge Full support 12Firefox Full support YesIE Full support YesOpera Full support YesSafari Full support YesWebView Android Full support YesChrome Android Full support YesEdge Mobile Full support YesFirefox Android Full support YesOpera Android Full support YesSafari iOS Full support YesSamsung Internet Android Full support Yes

Legend

Full support  
Full support

See also

Document Tags and Contributors

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