VOOZH about

URL: https://www.geeksforgeeks.org/html/html-textareamaxlength-attribute/

⇱ HTML <textarea> maxlength attribute - GeeksforGeeks


  • Courses
  • Tutorials
  • Interview Prep

HTML <textarea> maxlength attribute

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 Examples

Example: This example illustrates the use of textarea max length property in an HTML document.

Output:

👁 HTML <Textarea> maxlength attribute

Explanation:

  • In the above example we Includes a textarea with a maxlength attribute set to 9.
  • A form consists of a name input field and a submit button.
  • Styled with centered text and fieldset margin.

HTML Textarea maxlength attribute Use Cases

1. How to specify minimum &maximum number of characters allowed in an input field in HTML ?

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 JavaScript

To 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 Browsers

Comment