Skip to content
Related Articles

Related Articles

Improve Article
Save Article
Like Article

HTML | input maxlength Attribute

  • Last Updated : 23 Aug, 2019

The <input> maxlength attribute is used to specify the maximum number of characters enters into the <input> element.

Syntax:

Attention reader! Don’t stop learning now. Get hold of all the important HTML concepts with the Web Design for Beginners | HTML  course.

<input maxlength="number">

Attribute Value:

  • number: It contains single value number which allows the maximum number of character in <input> element. Its default value is 524288.

Example:




<!DOCTYPE html>
<html>
  
<head>
    <title>
        HTML input maxlength Attribute
    </title>
</head>
  
<body>
    <center>
        <h1 style="color:green;"
            GeeksforGeeks 
        </h1>
  
        <h2
            HTML <input> maxlength Attribute
        </h2>
  
        <form action="#">
            Username:
            <input type="text"
                   name="usrname"
                   maxlength="12">
  
            <br>
            <br> Password:
            <input type="text" 
                   name="password" 
                   maxlength="10">
  
            <br>
            <br>
  
            <input type="submit" 
                   value="Submit">
        </form>
    </center>
</body>
  
</html>

Output:

Supported Browsers: The browsers supported by input maxlength Attribute are listed below:

  • Google Chrome 1.0
  • Internet Explorer 2.0
  • Firefox 1.0
  • Safari 1.0
  • Opera 1.0



My Personal Notes arrow_drop_up
Recommended Articles
Page :

Start Your Coding Journey Now!