Change the width of a search field:
The size property sets or returns the value of the size attribute of a search field.
The size attribute specifies the width of a search 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.
The size property is supported in all major browsers.
Return the size property:
Set the size property:
Value | Description |
---|---|
number | Specifies the width of the search field, in number of characters. Default value is 20 |
Return Value: | A Number, representing the width of the search field, in number of characters |
---|
Display the width of a search field (in number of characters):
The result of x will be:
HTML reference: HTML <input> size attribute