HTML Attributes
HTML minlength attribute
Sets the minimum length of user-entered nonempty text in applicable fields, measured in UTF-16 code units. Add required if an empty value must also be invalid. Applicable elements include: <input>, <textarea>. Check each element’s value rules. Length constraints count UTF-16 code units rather than grapheme clusters. An empty optional control does not fail minlength. Length constraints are tied to user-edited values; assigning value from script is not an equivalent test of native validation.
Formal Syntax & Structure
html syntaxhtml
minlength="3"Parameters & Attributes
| Name | Type | Description |
|---|---|---|
| minlength | non-negative integer | Sets the minimum length of user-entered nonempty text in applicable fields, measured in UTF-16 code units. Add required if an empty value must also be invalid. |
Working Example
Example Snippethtml
<label> Nickname <input minlength="3" required></label>Browser Compatibility
Minimum supported versions across modern rendering engines
Blink (modern)
Chrome
40
Yes
EdgeHTML / Blink
Edge
17
Yes
Gecko
Firefox
51
Yes
WebKit
Safari
10.1
Yes
Desktop support for minlength on input only; other elements, input types, individual values and mobile behavior may differ.
HTML Living Standard