Latest web development tutorials

HTML DOM Input Text size attribute

Input Text Object Reference Input Text Object

Examples

Set the size of the text field (in order to count the number of characters):

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

try it"


Definition and Usage

size property sets or returns the size property values ​​in the text field.

size property sets or returns the size of the text field (in order to count the number of characters).

The default value is 20.

Tip: If you want to set or to return the number of characters allowed to enter the password field, use the maxLength property.


Browser Support

Internet ExplorerFirefoxOperaGoogle ChromeSafari

All major browsers support the size attribute


grammar

Returns size properties:

textObject .size

Set size properties:

textObject .size = number

Property Value

Value < description
number Track the size of the text field, in characters. The default value is 20.

Technical details

return value: Number that represents the size of the text field, in characters


More examples

Examples

Get the size of the text field:

. Var x = document.getElementById ( "myText") size;

x The output is:

30

try it"


Related Pages

HTML Reference Manual: HTML <the INPUT> size attributes


Input Text Object Reference Input Text Object