Canvas Createlineargradient
π
2026-06-18 | π HTML
## HTML Canvas `createLinearGradient()` Method
The `createLinearGradient()` method of the Canvas 2D API creates a linear gradient along the line given by the coordinates represented by the parameters.
This method returns a linear `CanvasGradient` object. To apply the gradient to shapes, you assign this object to the canvas context's `fillStyle` or `strokeStyle` properties. You can then define color transitions along the gradient line using the `addColorStop()` method.
---
## Browser Support
The `createLinearGradient()` method is fully supported by all modern web browsers:
* Google Chrome
* Mozilla Firefox
* Microsoft Edge / Internet Explorer 9+
* Safari
* Opera
*Note: Internet Explorer 8 and earlier versions do not support the `