X
HOME HTML CSS JAVASCRIPT SQL PHP JQUERY XML ASP.NET MORE...
REFERENCES | EXAMPLES | FORUM | ABOUT

Input Search size Property

Input Search Object Reference Input Search Object

Example

Change the width of a search field:

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

Try it yourself »


Definition and Usage

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.


Browser Support

Internet Explorer Firefox Opera Google Chrome Safari

The size property is supported in all major browsers.


Syntax

Return the size property:

searchObject.size

Set the size property:

searchObject.size=number

Property Values

Value Description
number Specifies the width of the search field, in number of characters. Default value is 20

Technical Details

Return Value: A Number, representing the width of the search field, in number of characters


More Examples

Example

Display the width of a search field (in number of characters):

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

The result of x will be:

35

Try it yourself »


Related Pages

HTML reference: HTML <input> size attribute


Input Search Object Reference Input Search Object

Your suggestion:

Close [X]

Thank You For Helping Us!

Your message has been sent to W3Schools.

Close [X]
Search w3schools.com:

WEB BUILDING

Download XML Editor FREE Website BUILDER Free HTML5 Templates FREE Website Templates Free HTML Templates

SHARE THIS PAGE

facebook