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.



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">

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.

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).

Browser support

Here is when width support started for each browser:

1.0 Sep 2008
16.0 Oct 2012
1.0 Aug 1995
1.0 Jan 2006
1.0 Jan 2003

You may also like

 Back to <input>

Last updated on Sep 30, 2023