English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية

HTML Referenzhandbuch

Vollständiges Verzeichnis der HTML-Tags

HTML: <input> width-Eigenschaft

HTML input width-Eigenschaft legt die Breite des <input>-Elements fest, die width-Eigenschaft ist nur für <input type="image"> gültig. Wenn height und width gesetzt sind, wird beim Laden der Seite der erforderliche Raum für das Bild beibehalten.

 HTML <input> Tag

Online-Beispiel

Definieren Sie das Bild als Submit-Button, die Größen der Eigenschaften height und width:45Pixel:

<!DOCTYPE html>
<html>
<head>
<title>HTML: <input> width-Eigenschaft - Grundlagen-Tutorial-Website(oldtoolbag.com)</title>
<body>
<form action="action_page.php">
  Vorname: <input type="text" name="fname"><br>
  Nachname: <input type="text" name="lname"><br>
  <input type="image" src="img_submit.gif" alt="Submit" width="45"height="45">
</form>
</body>
</html>
Test it out ‹/›

Browser Compatibility

IEFirefoxOperaChromeSafari

All major browsers support the width attribute.

Definition and Usage

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 loading (when the image is loading).

HTML 4.01 and HTML5difference between

The width attribute is an HTML5 New attribute of the <input> tag in the <input> tag.

Syntax

<input width="pixels">

Attribute Value

ValueDescription
pixelsWidth in pixels (e.g. width="100")。
 HTML <input> Tag