HTML <input> maxlength Attribute

❮ HTML <input> tag


<form action="action.php">
  <label for="username">Username:</label>
  <input type="text" id="username" name="username" minlength="6" maxlength="10">

  <label for="pasw">Password:</label>
  <input type="password" id="pasw" name="password" minlength="8" maxlength="16">

  <input type="submit" value="Submit">


The maxlength attribute specifies the maximum content length that can be entered in a text form control.

The maximum number of characters allowed differs from the visible dimension of the form control, which is set with the size attribute.

Default value is 524288.

maxlength attribute is valid for password, search, tel, text, url

Standard Syntax

HTML: <input maxlength="number">

XHTML: <input maxlength="number"/>

Browser Support


Attribute Values

Value Description
number Specifies the maximum number of characters allowed in the <input> element. (Default value is 524288)
❮ HTML <input> tag