Input Search size Property
Example
Change the length of the search field:
document.getElementById("mySearch").size = "50";
Try it »
Definition and Usage
The size property sets or returns the value of the size attribute of the search field.
The size property describes the length of the search field (number of characters).
The default value is 20.
Tip: If you need to set the maximum number of characters allowed in the search field, use maxLength attribute.
Browser support





All major browsers support the size property.
Syntax
Return the size property:
searchObject
.size
Set the size property:
searchObject
.size=
number
Attribute values
| Value | Description |
|---|---|
| number | Describes the length of the search field, in characters. The default value is 20. |
Technical Details
| Return Value: | A number representing the length of the search field, in characters. |
|---|
More examples
Example
Display the length of the search field (number of characters):
var x = document.getElementById("mySearch").size;
x
The output is:
35
Try it »
Related pages
HTML Reference Manual: HTML size property
Input Search Object