Web/API/CanvasRenderingContext2D/canvas

From Get docs


The CanvasRenderingContext2D.canvas property, part of the Canvas API, 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 StandardThe definition of 'CanvasRenderingContext2D.canvas' in that specification. Living Standard  

Browser compatibility

Update compatibility data on GitHub

Desktop Mobile
Chrome Edge Firefox Internet Explorer Opera Safari Android webview Chrome for Android Firefox for Android Opera for Android Safari on iOS Samsung Internet
canvas Chrome

Full support Yes

Edge

Full support 12

Firefox

Full support 1.5

IE

Full support Yes

Opera

Full support Yes

Safari

Full support Yes

WebView Android

Full support Yes

Chrome Android

Full support Yes

Firefox Android

Full support 4

Opera Android

Full support Yes

Safari iOS

Full support Yes

Samsung Internet Android

Full support Yes

Legend

Full support  
Full support


See also