maxlength caps input and textarea length in Chrome 4+, Edge 12+, Firefox 4+, Safari 5.1+, IE 10+, and iOS Safari 4+. Test it on real browsers.

Prince Dewani
May 6, 2026
The HTML maxlength attribute caps how many UTF-16 code units a user can type into an input or textarea field. It works in Chrome 4+, Edge 12+, Firefox 4+, Safari 5.1+, Opera 15+, IE 10+, iOS Safari 4+, Samsung Internet 4+, and Android Browser 2.3+; IE 6 to 9 and Safari 3.2 to 4 have partial support.
This guide covers what maxlength is, the browsers that support it, how it works, why it fails, and known issues to test.
The maxlength attribute is a standard HTML form attribute defined by the WHATWG HTML living specification. It limits the length of text a user can enter into an input element (in text, search, tel, url, email, or password mode) or a textarea. The browser stops further typing once the limit is reached.
maxlength is a Baseline Widely available feature with around 97 percent global support, but a handful of older engines and edge browsers ship only partial support that you still need to test for.
Chrome supports maxlength by default from Chrome 4 on for both desktop and Android. Every current Chrome release enforces the cap on input and textarea with no flag, and Chrome on Android matches the desktop behavior.
Edge supports maxlength by default from Edge 12 on across Windows, macOS, and Linux. Both the legacy EdgeHTML build and the current Chromium-based Edge enforce the limit by default, with no behavioral difference from Chrome.
Firefox supports maxlength by default from Firefox 4 on for desktop and Android. Firefox 2 to 3.6 had partial support, where the attribute was honored on input but the textarea element ignored it. Modern Firefox treats both elements consistently.
Safari supports maxlength by default from Safari 5.1 on macOS and Safari 4 on iOS. Safari 3.2 to 4 on macOS and Safari 8 to 8.4 on iOS had partial support, where the attribute was read but not always enforced on the textarea element. Always check paste behavior on Safari before shipping a length cap.
Opera supports maxlength by default from Opera 15 on, the first Chromium-based release. Opera 9.5 to 12.1 had partial support under the older Presto engine, and Opera Mini still ships only partial support because it serializes pages through a proxy that strips client-side validation.
Samsung Internet supports maxlength by default from Samsung Internet 4 on every Android version it ships on. The behavior tracks Chrome on Android closely because both engines run on Blink, but Samsung keyboards on Galaxy devices have surfaced paste regressions that warrant a separate test pass.
The legacy Android Browser, the WebView that shipped before Chrome on Android took over, supports maxlength from Android 2.3 on. This only matters on legacy hardware and pre-installed WebViews; modern Android devices route web content through Chromium WebView, which mirrors Chrome behavior.
Internet Explorer supports maxlength by default from IE 10 on. IE 6 to 9 had partial support, where the attribute capped keystroke input but did not enforce paste events or programmatic value changes. Microsoft has retired Internet Explorer, so this only matters for intranet apps still locked to legacy IE.
Note: maxlength behaves differently across Safari, Android Chrome, and Samsung Internet on real devices. Test it on real browsers and OS with TestMu AI. Try TestMu AI free!
maxlength tells the browser to stop accepting user keystrokes once the field value reaches the declared length, measured in UTF-16 code units. It runs as part of the HTML constraint validation API, and the browser exposes a tooLong flag on the field's ValidityState whenever the value somehow exceeds the cap.
Use feature detection to confirm the platform supports the maxLength DOM property and read ValidityState.tooLong to react when a user crosses the bound.
// Feature-detect maxlength on the platform
const probe = document.createElement('input');
const supportsMaxLength = 'maxLength' in probe;
console.log(supportsMaxLength ? 'maxlength supported' : 'maxlength missing');
// Watch a real field and react when the user hits the cap
const username = document.querySelector('#username');
username.addEventListener('input', () => {
if (username.validity.tooLong) {
console.log('User typed past the maxlength bound');
}
});The attribute itself is supported across every modern engine, so when maxlength looks broken the cause is almost always one of four mistakes in the markup or framework wiring above it.
In my experience, the React camelCase trap is the single most common production bug we see for this attribute, and it ships silently because lint rules rarely flag a missing maxLength.
maxlength has a wide support footprint, but the edge cases break in browser-specific ways that only show up on real devices.
All maxlength version numbers, behavior notes, and platform claims in this guide come from these primary sources:
Did you find this page helpful?
More Related Hubs
TestMu AI forEnterprise
Get access to solutions built on Enterprise
grade security, privacy, & compliance