Easy Tutorial
❮ Prop Hidden Name Prop Element Firstelementchild ❯

Input Search size Attribute

Input Search Object

Example

Modify the length of the search field:

document.getElementById("mySearch").size = "50";

Definition and Usage

The size attribute is used to set or return the value of the search field's size attribute.

The size attribute describes the length of the search field in characters.

The default value is 20.

Tip: If you need to set the maximum number of characters allowed in the search field, use the maxLength attribute.


Browser Support

All major browsers support the size attribute.


Syntax

Return the size attribute:

Set the size attribute:

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 (in characters):

var x = document.getElementById("mySearch").size;
35

Related Pages

HTML Reference: HTML <input> size Attribute


❮ Prop Hidden Name Prop Element Firstelementchild ❯