Categories
JavaScript Answers

How to set element width or height in JavaScript?

Spread the love

Sometimes, we want to set element width or height in JavaScript.

In this article, we’ll look at how to set element width or height in JavaScript.

How to set element width or height in JavaScript?

To set element width or height in JavaScript, we set the style.width and style.height properties.

For instance, we write

e1.style.width = "400px";
e1.style.height = "200px";

to set the width of the el element to 400px and the height of el to 200px.

Conclusion

To set element width or height in JavaScript, we set the style.width and style.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 *