The width attribute on an <input> tag sets the width of the image.
This only applies to <input> buttons of type image.
The width is specified in pixels -- without the ‘px‘ unit.
A width attribute on an image <input> element.
The width attribute overrides the original image input width.
<form action="/tutorial/action.html">
<label for="firstname">First name</label> <br />
<input type="text" id="firstname" name="firstname"> <br />
<label for="lastname">Last name</label> <br />
<input type="text" id="lastname" name="lastname"> <br /><br />
<input type="image" src="/img/html/arrow.png"
width="40" height="40" alt="Submit">
</form>
The width attribute specifies the width of the input element.
This attribute only applies to <input> elements of type image.
The width is defined in pixels, without the 'px' extension.
To define the width in % or other unit, use the CSS width property.
Note: Image width can also be defined with CSS. If both the width attribute and CSS width
property are specified, CSS takes precedence (wins).
<input type="image" width="pixels">
Value | Description |
---|---|
pixels | Numeric value. The image width in pixels (e.g. 150). |
Here is when width support started for each browser:
Chrome
|
1.0 | Sep 2008 |
Firefox
|
16.0 | Oct 2012 |
IE/Edge
|
1.0 | Aug 1995 |
Opera
|
1.0 | Jan 2006 |
Safari
|
1.0 | Jan 2003 |