HTML <input> sizeAttribute
Examples
The two input fields in the following HTML form have widths of 35 characters and 4 characters respectively:
<form
action="demo_form.html">
Email: <input type="text" name="email" size="35"><br>
PIN: <input type="text" name="pin" maxlength="4" size="4"><br>
<input type="submit" value="提交">
</form>
Email: <input type="text" name="email" size="35"><br>
PIN: <input type="text" name="pin" maxlength="4" size="4"><br>
<input type="submit" value="提交">
</form>
Try it Yourself »
Browser Support
![]()
![]()
![]()
![]()
![]()
All major browsers support the size attribute.
Definition and Usage
The size attribute specifies the visible width of an <input> element, in characters.
Note:The size attribute applies to the following input types: text, search, tel, url, email, and password.
Tip:To specify the maximum number of characters allowed in an <input> element, use themaxlengthattribute.
Differences between HTML 4.01 and HTML5
None.
Syntax
<input size="number">
Attribute Values
| Value | Description |
|---|---|
| number | Specifies the width of an <input> element, in characters. The default value is 20. |
HTML <input> Tag Other Extensions