HTML maxlength Attribute
It specifies the maximum number of characters that have been allowed in the Element.
It can be used on the Following Elements:
- <input>
- <textarea>
Examples:
- Example for <input> element:
<!DOCTYPE html><html><body><center><h1style="color:green;font-style:italic;">GeeksForGeeks</h1><h2style="color:green;font-style:italic;">maxlength attribute</h2><formaction="">Username:<inputtype="text"name="usrname"maxlength="12"><br><br>Password:<inputtype="text"name="password"maxlength="10"><br><br><inputtype="submit"value="Submit"></form></center></body></html>chevron_rightfilter_noneOutput:

- Example for <textarea> element:
<!DOCTYPE html><html><body><center><h1style="color:green;font-style:italic;">GeeksforGeeks</h1><h2style="color:green;font-style:italic;">maxlength attribute</h2><textarearows="4"cols="50"maxlength="6">write here somthing that you want....</textarea></center></body></html>chevron_rightfilter_noneOutput:

Supported Browsers: The browsers supported by maxlength attribute are listed below:
- Google Chrome
- Internet Explorer
- Firefox
- Opera
- Safari
Recommended Posts:
- HTML | DOM Textarea maxlength Property
- HTML | DOM Input URL maxLength Property
- HTML | DOM Input Text maxLength Property
- HTML | DOM Input Search maxLength Property
- HTML | DOM Input Email maxLength Property
- HTML | DOM Input Password maxLength Property
- AngularJS | ng-maxlength Directive
- HTML | <a> rel Attribute
- HTML | <img> alt Attribute
- HTML | dir Attribute
- HTML | <map> name Attribute
- HTML | <li> value Attribute
- HTML | value Attribute
- HTML | for Attribute
- HTML | min Attribute
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.



