Input Search size Attribute
Definition and Usage
size
The attribute sets or returns the value of the size attribute of the search field.
The HTML size attribute specifies the width of the search field (in characters), with a default value of 20.
Tip:To set or return the maximum number of allowed characters in the password field, use maxLength Attribute.
See also:
HTML Reference Manual:HTML <input> size Attribute
Example
Example 1
Change the width of the search field:
document.getElementById("mySearch").size = "50";
Example 2
Display the width of the search field (in characters):
var x = document.getElementById("mySearch").size;
Syntax
Return the size attribute:
searchObject.size
Set size attribute:
searchObject.size = number
Attribute Value
Value | Description |
---|---|
number | Specifies the width of the search field in terms of the number of characters. The default value is 20. |
Technical Details
Return Value: | Number, representing the width of the search field in characters. |
---|
Browser Support
Chrome | Edge | Firefox | Safari | Opera |
---|---|---|---|---|
Chrome | Edge | Firefox | Safari | Opera |
Support | Support | Support | Support | Support |