Input Text size property
Example
Set the size of the text field (in number of characters):
document.getElementById("myText").size = "50";
Try it »
Definition and Usage
The size property is used to set or return the size property value of the text field.
The size property sets or returns the size of the text field (in number of characters).
The default value is 20.
Tip: To set or return the number of characters allowed in a password field, use maxLength attribute.
Browser support

All major browsers support the size property
Syntax
Return the size property:
textObject
.size
Set the size property:
textObject
.size=
number
Attribute values
| Value< | Description |
|---|---|
| number | Tracks the size of the text field, in characters. The default value is 20. |
Technical details
| Return Value: | Number, representing the size of the text field, in characters |
|---|
More examples
Example
Get the size of the text field:
var x = document.getElementById("myText").size;
x The output is:
30
Try it »
Related pages
HTML Reference Manual: HTML size property
The Input Text object