2D canvasBaseline · Widely available
The CanvasRenderingContext2D API is the "2d" rendering context for the <canvas> element. It represents a flat, two-dimensional space for drawing graphics and animations.
Supported in all major browsers for at least 30 months — safe to use without fallbacks. Baseline since Jul 29, 2015. Widely available since Jan 29, 2018.
Browser support
DesktopChrome
1+Supportedsince Dec 11, 2008
Current: 155Edge
12+Supportedsince Jul 29, 2015
Current: 154Firefox
1–1Not supported
1.5+Supportedsince Nov 29, 2005
Current: 157Safari
1–1.3Not supported
2+Supportedsince Apr 29, 2005
Current: 27MobileChrome Android
18+Supportedsince Jun 27, 2012
Current: 155Firefox Android
4+Supportedsince Mar 29, 2011
Current: 157Safari iOS
1+Supportedsince Jun 29, 2007
Current: 27How to use
This feature is Baseline widely available — use it freely, no fallback needed.
Example
Full syntax and examples are on MDN: CanvasGradient.
Feature detection
JS · check before using
if ("CanvasGradient" in globalThis) {
// CanvasGradient is available
} else {
// load a polyfill or use a fallback
}Sub-features
Support for each part of the feature (117). The overall table above shows when the whole feature works.
| Sub-feature | Chrome | Edge | Firefox | Safari | Chrome Android | Firefox Android | Safari iOS |
|---|---|---|---|---|---|---|---|
| CanvasGradient | 1 | 12 | 1.5 | 2 | 18 | 4 | 1 |
| CanvasGradient.addColorStop | 1 | 12 | 1.5 | 2 | 18 | 4 | 1 |
| CanvasPattern | 1 | 12 | 1.5 | 2 | 18 | 4 | 1 |
| CanvasPattern.setTransform | 68 | 79 | 33 | 11.1 | 68 | 33 | 11.3 |
| CanvasPattern.setTransform.dommatrix | 68 | 79 | 79 | 11.1 | 68 | 79 | 11.3 |
| CanvasRenderingContext2D | 1 | 12 | 1.5 | 2 | 18 | 4 | 1 |
| CanvasRenderingContext2D.arc | 1 | 12 | 1.5 | 3 | 18 | 4 | 1 |
| CanvasRenderingContext2D.arcTo | 1 | 12 | 1.5 | 2 | 18 | 4 | 1 |
| CanvasRenderingContext2D.beginPath | 1 | 12 | 1.5 | 2 | 18 | 4 | 1 |
| CanvasRenderingContext2D.bezierCurveTo | 1 | 12 | 1.5 | 2 | 18 | 4 | 1 |
| CanvasRenderingContext2D.canvas | 1 | 12 | 1.5 | 3 | 18 | 4 | 1 |
| CanvasRenderingContext2D.clearRect | 1 | 12 | 1.5 | 2 | 18 | 4 | 1 |
| CanvasRenderingContext2D.clip | 1 | 12 | 1.5 | 2 | 18 | 4 | 1 |
| CanvasRenderingContext2D.clip.path_parameter | 36 | 14 | 31 | 7 | 36 | 31 | 7 |
| CanvasRenderingContext2D.closePath | 1 | 12 | 1.5 | 2 | 18 | 4 | 1 |
| CanvasRenderingContext2D.createImageData | 2 | 12 | 3.5 | 4 | 18 | 4 | 3.2 |
| CanvasRenderingContext2D.createLinearGradient | 1 | 12 | 1.5 | 2 | 18 | 4 | 1 |
| CanvasRenderingContext2D.createPattern | 1 | 12 | 1.5 | 2 | 18 | 4 | 1 |
| CanvasRenderingContext2D.createRadialGradient | 1 | 12 | 1.5 | 2 | 18 | 4 | 1 |
| CanvasRenderingContext2D.direction | 77 | 79 | 101 | 9 | 77 | 101 | 9 |