Use the width property in JavaScript to set the width of an element.
Example
You can try to run the following code to learn how to set the width of an element in JavaScript −
<!DOCTYPE html> <html> <body> <button type="button" id="btn" onclick="display()"> Change height and width </button> <script> function display() { document.getElementById("btn").style.width = "250px"; document.getElementById("btn").style.height = "250px"; } </script> </body> </html>