You are here: Reference > JavaScript > client-side > HTML DOM > properties > size (input, isindex)

size property (input, isindex)

Browser support:
Specifies or returns the width of a control, in characters.
The width is calculated by the average character widths. You can set the dimensions of the input field by the width and the height style properties.

Syntax:

object.size;
You can find the related objects in the Supported by objects section below.
This property is read/write.
HTML page for this property: size

Possible values:

Integer that sets or retrieves the width of the control, in characters. The default is 20.
Default: this property has no default value.

Example HTML code 1:

This example illustrates the use of the size attribute:
Input field with size=20:
<br />
<input id="myInput" type="text" size="20" />
<br /><br /><br />
Input field with size=30:
<br />
<input id="myInput" type="text" size="30" />
Did you find this example helpful? yes no

Example HTML code 2:

This example illustrates the use of the size property:
<head>
    <script type="text/javascript">
        function SetSize () {
            var input = document.getElementById ("myInput");
            input.size = input.value;
        }
    </script>
</head>
<body>
    <input id="myInput" type="text" value="70" size="30" />

    <br />
    Change the value of the input field!
    <button onclick="SetSize ();">Change input size!</button>
</body>
Did you find this example helpful? yes no

Supported by objects:

Related pages:

External links:

User Contributed Comments

Post Content

Post Content