HTML <input> maxlength Attribute
Definition and Usage
maxlength
Attribute specifies the maximum number of characters allowed in the <input> element.
Example
An <input> element with a maximum length of 10 characters:
<form action="/action_page.php"> <label for="username">Username:</label> <input type="text" id="username" name="username" maxlength="10"><br><br> <input type="submit" value="Submit"> </form>
Syntax
<input maxlength="number">
Attribute Value
Value | Description |
---|---|
number | The maximum number of characters allowed in the <input> element. The default value is 524288. |
Browser Support
Chrome | Edge | Firefox | Safari | Opera |
---|---|---|---|---|
Chrome | Edge | Firefox | Safari | Opera |
Support | Support | Support | Support | Support |