References

Beginner-friendly references for web development, with live, editable examples.

The HTML autocapitalize attribute

Global attribute Works on every element All modern browsers Updated
Quick answer

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

Live 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.

Frequently asked questions

What does the autocapitalize attribute do?
Controls how on-screen keyboards automatically capitalize text the user enters.
Are these attributes guaranteed to work?
No. They are hints that browsers and on-screen keyboards may honor or ignore, especially on desktop.
Which elements do they apply to?
They are global attributes, but they mainly affect editable and form fields.
Is autocapitalize a global attribute?
Yes — it is a global attribute, so it can be set on any HTML element (it is a global attribute), most usefully on editable and form fields.