The width attribute is used to specify the width of an input element, mainly for image-type inputs. It helps control the displayed size of the image button.
- Sets the width of an <input type="image"> element in pixels.
- Helps adjust the size of image-based submit buttons.
- Commonly used together with the height attribute for proper dimensions.
Syntax:
<input width="pixels"> Attribute Values: It contains the value i.e pixels which specify the width of the input Element.
<!--Driver Code Starts-->
<!DOCTYPE html>
<html>
<!--Driver Code Ends-->
<body style="text-align:center;">
<h1 style="color:green;">
GeeksForGeeks
</h1>
<h2>HTML Input width Attribute</h2>
<input id="myImage"
type="image"
src=
"https://media.geeksforgeeks.org/wp-content/uploads/gfg-40.png"
alt="Submit"
width="48"
height="48" />
</body>
<!--Driver Code Starts-->
</html>
<!--Driver Code Ends-->