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 (the default for most fields) 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
- Use inputmode to bring up the right on-screen keyboard (numeric, email, and so on).
- Set autocapitalize appropriately — off for names and codes, sentences for prose.
- These are hints; do not rely on them for validation.
- Test on real mobile devices, where most of these take effect.