HTML maxlength Attribute

❮ HTML Attributes


<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">


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">

Browser Support


Applies to:

The maxlength attribute can be used on the following element:

Element Attribute
<input> maxlength
<textarea> maxlength

Attribute Values

Value Description
number Specifies the maximum number of characters allowed in the text area.
❮ HTML Attributes