The Input Image width Property In HTML DOM is used to return the value of the width attribute of the <input type=”image”>.
Syntax:
- To returns the width Property.
imageObject.width
- To sets the width Property.
imageObject.width = value;
Property Value: It contains the numeric value which specifies the width of the image in terms of pixels.
Return Value: It returns a numeric value which represents the width of the image.
Example 1: This Example returns the Input Image width Property.
<!DOCTYPE <html> <head> <title> HTML DOM Input Image width Property </title> </head> <body style="text-align:center;"> <h1 style="color:green;"> GeeksforGeeks </h1> <h4> DOM Input Image width Property </h4> <button onclick="my_geek()"> <input id="myImage" type="image" src= alt="Submit" formaction="#" formtarget="#" formenctype="text/plain" width="48" height="48"> </button> <h2 id="Geek_h" style="color:green;"></h2> <script> function my_geek() { // Return formTarget, formEnctype and formAction. var txt = document.getElementById( "myImage").width; document.getElementById( "Geek_h").innerHTML = txt; } </script> </body> </html> |
Output:
- Before Clicking On Button:

- After Clicking On Button:

Example 2: This Example sets the Input Image width Property.
<!DOCTYPE html> <html> <head> <title> HTML DOM Input Image width Property </title> </head> <body style="text-align:center;"> <h1 style="color:green;"> GeeksforGeeks </h1> <h4> DOM Input Image width Property </h4> <button onclick="my_geek()"> <input id="myImage" type="image" src= alt="Submit" formaction="#" formtarget="#" formenctype="text/plain" width="48" height="48"> </button> <h2 id="Geek_h" style="color:green;"></h2> <script> function my_geek() { // Return formTarget, formEnctype and formAction. var txt = document.getElementById( "myImage").width = "96"; document.getElementById( "Geek_h").innerHTML = txt; } </script> </body> </html> |
Output:
- Before Clicking On Button:

- After Clicking On Button:

Supported Browsers: The browsers supported by HTML DOM Input Image width Property are listed below:
- Google Chrome
- Internet Explorer
- Firefox
- Opera
- Safari
Recommended Posts:
- HTML | DOM Input Image alt Property
- HTML | DOM Input Image name Property
- HTML | DOM Input Image value Property
- HTML | DOM Input Image src Property
- HTML | DOM input image height Property
- HTML | DOM Input Image formEnctype Property
- HTML | DOM Input Image formTarget Property
- HTML | DOM Input Image formNoValidate Property
- HTML | DOM Input image autofocus Property
- HTML | DOM Input Image disabled Property
- HTML | DOM Input Image formMethod Property
- HTML | DOM Input Image formAction Property
- HTML | DOM Input Image type Property
- HTML | DOM Input Image form Property
- CSS | border-image-width Property
- HTML | <input> width Attribute
- HTML width/height Attribute vs CSS width/height Property
- HTML | DOM HR width Property
- HTML | DOM Pre width Property
- HTML | DOM Style width Property
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.
Improved By : nidhi_biet


