Advertisement
Home Open Editor ❯

HTML maxlength Attribute

Example

<form action="action.php">
  <label for="username">Username:</label>
  <input type="text" id="username" name="username" minlength="6" maxlength="10"><br><br>
  <label for="pasw">Password:</label>
  <input type="password" id="pasw" name="password" minlength="8" maxlength="16"><br><br>
  <input type="submit" value="Submit">
</form>

Try this code ❯

Meaning

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.


Standard Syntax

<element maxlength="number">


Applies to:

The maxlength attribute can be used on the following element:


Advertisement

Attribute Values

Value Description
number Specifies the maximum number of characters allowed in the text area.
Home Open Editor ❯
Advertisement