Latest web development tutorials

HTML input width attribute

HTML input Tag Reference HTML <input> tag

Examples

Custom image as the submit button, with the height and width attributes:

<form action="demo_form.html">
First name: <input type="text" name="fname"><br>
Last name: <input type="text" name="lname"><br>
<input type="image" src="img_submit.gif" alt="Submit" width="48" height="48">
</form>

try it"

Browser Support

Internet ExplorerFirefoxOperaGoogle ChromeSafari

All major browsers support width attribute.


Definition and Usage

Attribute specifies the width <input> element width.

Note: width attribute applies only to <input type = "image"> .

Tip: Specify the height and width attributes for the picture is a good habit. If you set these properties, when the page loads will need to reserve space image. And without these attributes, the browser will not be able to understand the dimensions of the image, it can not be reserved for a suitable space. It is when the page is loaded and pictures, page layout will change.


Differences between HTML 4.01 and HTML5

width attributes are new attributes in HTML5 <input> tag.


grammar

<input width="pixels">

Property Value

描述
pixels 以像素计的宽度(比如 width="100")。


HTML input Tag Reference HTML <input> tag