autocorrect
The autocorrect global attribute is an enumerated attribute that controls whether autocorrection of editable text is enabled for spelling and/or punctuation errors.
The specific autocorrection behavior, including which words are substituted, depends on the user agent and the services provided by the underlying device. For example, on macOS a user agent might rely on registered replacement text and punctuation. Other devices and browsers may use a different approach.
Autocorrection is relevant to editable text elements:
<input> elements, except for password, email, and url, which do not support autocorrection.
<textarea> elements.
Any element that has the contenteditable attribute set.
Editable elements have auto-correction enabled by default, except for within a <form> element, where the default value may be inherited from the form. Explicitly setting the attribute overrides the default.
Browser support
| Feature | Desktop | Mobile | ||||
|---|---|---|---|---|---|---|
| Chrome | Edge | Firefox | Safari | Chrome Android | Safari iOS | |
| | | 136 | 14.1 | | 14.5 | |
| DOM API | ||||||
| The autocorrect property of the HTMLElement interface controls whether or not autocorrection of editable text is enabled for spelling and/or punctuation errors. | | | 136 | 14.1 | | 14.5 |
Syntax
<input type="text" autocorrect="off" placeholder="コード入力">
<textarea autocorrect="on">Standard text input</textarea> Live demo
Writing versus code
Keep autocorrect on for prose and off for usernames, tags, or code-like input.
Editable note board
Compare autocorrect support in two editable surfaces with different writing goals.
Use cases
-
Use autocorrect
Use autocorrect when standard HTML needs a more specific platform feature, semantic signal, or browser capability.
-
Handle edge cases
Apply autocorrect to solve a focused requirement without redesigning the whole page architecture.
Cautions
- Test autocorrect in your target browsers and input environments before depending on it as a primary behavior.
- Provide a fallback path or acceptable degradation strategy when support is still limited.
Accessibility
- Make sure autocorrect supports the intended task without making the page harder to perceive, understand, or operate.