The HTML autocapitalize attribute
The HTML autocapitalize attribute controls how on-screen keyboards automatically capitalize the text a user types in form fields and contenteditable elements. Values include none, sentences, words and characters. It is a global attribute, most relevant on touch devices.
Overview
The autocapitalize attribute hints to virtual keyboards how to auto-capitalize text as the user types. It has no effect on physical keyboards, and it does not change the value that is submitted, only what the on-screen keyboard suggests.
Use none (or off) for case-sensitive data like usernames and codes, characters for things like country or coupon codes, words for names, and sentences for ordinary prose.
Values
| Value |
|---|
| none (off) | sentences (on) | words | characters |
Example
<input type="text" autocapitalize="characters" placeholder="Type a code (ABC123)" style="padding:8px; width:100%;">
Best practices
- Setting autocapitalize on the <form> gives its fields a default, even fields linked to it with the form attribute. A field's own non-empty value overrides it, and a <fieldset> or
<div>passes nothing down. - To stop capitalization, write
noneoroff. An unknown value such asnoorfalseis read assentences, the opposite of what you meant. - Choose the value with dictation in mind. A virtual keyboard lets the user switch a suggested capital back to lowercase, but voice input may apply the hint without giving them that chance.
- Set a value wherever capitalization matters, since the unset default varies. Chrome and Safari capitalize sentences by default, while Firefox starts with none.
- Normalize letter case in your own code before you compare or store values such as coupon codes. Users can sometimes override the hint or edit the text afterward, so it must not be relied on for validation.























