Sometimes, we want to resize an HTML canvas element with JavaScript.
In this article, we’ll look at how to resize an HTML canvas element with JavaScript.
How to resize an HTML canvas element with JavaScript?
To resize an HTML canvas element with JavaScript, we set the canvas element’s width
and height
properties.
For instance, we write
canvasNode.width = 200;
canvasNode.height = 100;
to set the width and height of the canvas element.
Conclusion
To resize an HTML canvas element with JavaScript, we set the canvas element’s width
and height
properties.