HTML <input> width Attribute

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.

Example

#

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>

Using width

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.

Percentages (%) are not allowed, but most browsers do support it.

Note:  Image width can also be defined with CSS. If both the width attribute and CSS width property are specified, CSS takes precedence (wins).


Syntax

<input type="image" width="pixels">

Values

#

Value Description
pixels Numeric value. The image width in pixels (e.g. 150).

Browser support

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

You may also like

 Back to <input>
Guides