HTML - attributes - maxlength

revision:


Content

"maxlength" attribute : specifies maximum number of characters allowed syntax some examples


"maxlength" attribute : specifies maximum number of characters allowed

top

The maxlength attribute can be used on the following elements: <input> and <textarea>.
With respect to <input>, the attribute can be used on elements that accept string type value.


syntax

top

<textarea maxlength="number"></textarea>

<input maxlength="number"/>

number: it is the maximum number of characters allowed in an element. Its default value is 524288


some examples

top


codes:
                    <form style="margin-left:3vw;" 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>
                
codes:
                    <textarea style="margin-left:3vw;" rows="4" cols="50" maxlength="50">
                        Enter text here...</textarea>