Private archive copy · Unofficial site · Content copyright belongs to Runoob Tutorial and the original authors · View Original

HTML input width Attribute

HTML width property

HTML input Tag Reference HTML tag

Example

Define an image as a submit button with height and width attributes:

First name:

Last name:

Try it »


Browser support

Internet ExplorerFirefoxOperaGoogle ChromeSafari

All major browsers support the width property.


Definition and Usage

The width attribute specifies the The width of the element.

**Note:** The width attribute only applies to .

**Tip:** It is a good practice to specify the height and width attributes for an image. If these attributes are set, the required space is reserved for the image when the page loads. Without them, the browser cannot know the image's dimensions and cannot reserve appropriate space, so the page layout changes as the page and image load.


Differences between HTML 4.01 and HTML5

The width attribute is new in HTML5 for the tag.


Syntax

Attribute values

Value Description
pixels Width in pixels (such as width="100").

HTML input Tag Reference HTML tag