Categories
JavaScript Answers

How to resize an HTML canvas element with JavaScript?

Spread the love

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.

By John Au-Yeung

Web developer specializing in React, Vue, and front end development.

Leave a Reply

Your email address will not be published. Required fields are marked *