Input URL size attribute

Definition and Usage

size Sets or returns the value of the size attribute of the URL field.

The HTML size attribute specifies the width of the URL 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 the maxLength attribute.

See also:

HTML Reference Manual:HTML <input> size Attribute

Example

Example 1

Change the width of the URL field:

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

Try it yourself

Example 2

Display the width of the URL field (in characters):

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

Try it yourself

Syntax

Return the size attribute:

urlObject.size

Set size attribute:

urlObject.size = number

Attribute Value

Value Description
number Specifies the width of the URL field in characters. The default value is 20.

Technical Details

Return Value: A number, representing the width of the URL field, in characters.

Browser Support

Chrome Edge Firefox Safari Opera
Chrome Edge Firefox Safari Opera
Supported 10.0 Supported Not Supported Supported