English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية
The HTML input width attribute specifies the width of the <input> element. The width attribute is only applicable to <input type="image">. If height and width are set, the space required for the image is reserved when the page is loaded.
Define the image as a submit button, with height and width attributes of45Pixels:
<!DOCTYPE html> <html> <head> <title>HTML: <input> width attribute - 基础教程网(oldtoolbag.com)</title> <body> <form action="action_page.php"> 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="45"height="45"> </form> </body> </html>Test and see ‹/›
IEFirefoxOperaChromeSafari
All major browsers support the width attribute.
The width attribute specifies the width of the <input> element.
Note:The width attribute is only applicable to <input type="image">.
Tip:Always specify both the height and width attributes of the image. If height and width are set, the space required for the image is reserved when the page is loaded. However, if these attributes are not set, the browser will not know the size of the image and will not be able to reserve the appropriate space. The effect is that the page layout will change during the loading process (when the image is loaded).
The width attribute is an HTML5 new attribute of the <input> tag in the <input>.
<input width="pixels">
Value | Description |
---|---|
pixels | Width in pixels (for example width="100"). |