Last Updated : 12 Jul, 2025
The HTML <textarea> maxlength attribute is used to specify the maximum number of characters entered into the textarea element.
Syntax:
<textarea maxlength ="number">
Attribute Value:
Attribute Value
Description
number
It contains a single value number which allows the maximum number of characters in the Textarea element. Its default value is 524288.
HTML <textarea> maxlength attribute ExamplesExample: This example illustrates the use of textarea max length property in an HTML document.
HTML
<!DOCTYPE html>
<html>
<head>
<title>
textarea maxlength Attribute
</title>
<style>
body {
text-align: center;
}
</style>
</head>
<body>
<textarea
form="mygeeks"
maxlength="9"
></textarea>
<br />
<form id="mygeeks">
Name:
<input type="text" name="username" />
<input type="submit" />
</form>
</body>
</html>
Output:
Explanation:
To specify the minimum and maximum number of characters allowed in an input field in HTML, use the "minlength" and "maxlength" attributes, respectively, within the <input> tag.
2. Create a Character Limit Textarea using HTML CSS and JavaScriptTo create a character limit textarea: Use HTML <textarea> with a maxlength attribute, style with CSS, and validate input length with JavaScript. Update remaining characters dynamically.
Supported BrowsersRetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4