Text size Property
Text Object
Definition and Usage
The size property sets or returns the width of a text field (in number of
characters).
The default value is 20.
Syntax
Set the size property:
Return the size property:
Browser Support

The size property is supported in all major browsers.
Example
Example
Set the width of a text field:
<head>
<script>
function setResult()
{
document.getElementById("email").size=40;
}
</script>
</head>
<body>
<form>
Email: <input type="text" id="email">
</form>
<button type="button" onclick="setResult()">Set width</button>
</body>
</html>
Try it yourself »
Text Object
Thank You For Helping Us!
Your message has been sent to W3Schools.
Close [X]