Horje
HTML maxlength Attribute

Definition and Usage

The maxlength attribute specifies the maximum number of characters allowed in the element.


Applies to

The maxlength attribute can be used on the following elements:

Elements Attribute
<input> maxlength
<textarea> maxlength

Browser Support

The maxlength attribute has the following browser support for each element.


How to add An <input> element with a maximum length of 10 characters

Input Example.
index.html
Example: HTML
<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>

Output should be:

How to add An <input> element with a maximum length of 10 characters

How to add A text area with a maximum length of 50 characters

Textarea Example.
index.html
Example: HTML
 <textarea maxlength="50">
Enter text here...
</textarea> 

Output should be:

How to add A text area with a maximum length of 50 characters




html maxlength attribute

Type:
Develop
Category:
Web Tutorial
Sub Category:
HTML Attribute
Uploaded by:
Admin


Read Article
https://develop.horje.com/learn/1434/reference