Input Text size Property
Example
Set the width of a text field:
Description
The size property sets or returns the value of the size attribute of a text field.
The size attribute specifies the width of a text field (in number of characters).
The default value is 20.
Tip: To set or return the maximum number of characters allowed in the password field, use the maxLength property.
Browser Support
| Property | |||||
|---|---|---|---|---|---|
| size | Yes | Yes | Yes | Yes | Yes |
Syntax
Return the size property:
Set the size property:
Property Values
| Value | Description |
|---|---|
| number | Specifies the width of the text field, in characters. Default value is 20 |
Technical Details
| Return Value: | A Number, representing the width of the text field, in number of characters |
|---|
More Examples
Example
Get the width of a text field:
Related Pages
HTML reference: HTML <input> size attribute
❮ Input Text Object