Skip to content

The autocapitalize Attribute

Global Attribute

The autocapitalize attribute controls whether and how text input is automatically capitalized on mobile devices and virtual keyboards. It’s particularly useful for improving the user experience when entering names, sentences, or other text that benefits from automatic capitalization.

<element autocapitalize="value">Content</element>
ValueDescriptionUse Case
off or noneNo automatic capitalizationUsernames, email addresses, codes
on or sentencesCapitalize first letter of each sentenceComments, messages, paragraphs
wordsCapitalize first letter of each wordNames, titles, addresses
charactersCapitalize all charactersAcronyms, codes, license plates
Result
Result
Result
Result

On mobile devices with virtual keyboards:

  • none/off: Lowercase keyboard, no shift
  • sentences: First letter capitalized, then lowercase
  • words: Shift after each space
  • characters: Caps lock active

On desktop browsers:

  • The attribute is typically ignored
  • Users control capitalization manually
  • No automatic capitalization occurs

Choose the right value based on expected input:

<!-- Personal names: capitalize each word -->
<input type="text" name="fullName" autocapitalize="words">
<!-- Email: no capitalization -->
<input type="email" autocapitalize="none">
<!-- Comments/messages: sentence case -->
<textarea autocapitalize="sentences"></textarea>
<!-- Codes/IDs: all caps -->
<input type="text" name="productCode" autocapitalize="characters">
<!-- Usernames: no capitalization -->
<input type="text" name="username" autocapitalize="off">
<input
type="text"
autocapitalize="none"
autocorrect="off"
spellcheck="false"
placeholder="username">
<!-- Good: Street address -->
<input
type="text"
name="street"
autocapitalize="words"
placeholder="123 Main Street">
<!-- Good: City name -->
<input
type="text"
name="city"
autocapitalize="words"
placeholder="San Francisco">
<!-- Good: State abbreviation -->
<input
type="text"
name="state"
autocapitalize="characters"
maxlength="2"
placeholder="CA">
<!-- Email: Always use autocapitalize="none" -->
<input type="email" autocapitalize="none">
<!-- URL: No capitalization needed -->
<input type="url" autocapitalize="none">
<!-- Search: Depends on use case -->
<input type="search" autocapitalize="sentences">
<!-- Tel: Not affected -->
<input type="tel">
<!-- Password: Usually autocapitalize="none" -->
<input type="password" autocapitalize="none">
<!-- Works on contenteditable too -->
<div
contenteditable="true"
autocapitalize="sentences">
Type your content here...
</div>
<input type="text" name="firstName" autocapitalize="words" placeholder="John">
<input type="text" name="lastName" autocapitalize="words" placeholder="Smith">
<input type="text" name="jobTitle" autocapitalize="words" placeholder="Software Engineer">
<input type="text" name="street" autocapitalize="words" placeholder="Main Street">
<input type="text" name="city" autocapitalize="words" placeholder="New York">
<input type="text" name="state" autocapitalize="characters" placeholder="NY">
<input type="text" name="zipCode" autocapitalize="characters">
<input type="text" name="username" autocapitalize="none" placeholder="johndoe123">
<input type="email" name="email" autocapitalize="none" placeholder="[email protected]">
<input type="password" name="password" autocapitalize="none">
<!-- Blog post -->
<textarea name="content" autocapitalize="sentences"></textarea>
<!-- Comment -->
<textarea name="comment" autocapitalize="sentences" placeholder="Share your thoughts..."></textarea>
<!-- Review -->
<textarea name="review" autocapitalize="sentences" placeholder="Write your review..."></textarea>
<input type="text" name="promocode" autocapitalize="characters" placeholder="SAVE20">
<input type="text" name="licensekey" autocapitalize="characters">
<input type="text" name="confirmationCode" autocapitalize="characters">
const input = document.getElementById('myInput');
// Set autocapitalize
input.autocapitalize = 'words';
input.setAttribute('autocapitalize', 'words');
// Get current value
console.log(input.autocapitalize); // "words"
// Remove
input.removeAttribute('autocapitalize');
// Set based on input type
const emailInputs = document.querySelectorAll('input[type="email"]');
emailInputs.forEach(input => {
input.autocapitalize = 'none';
});
// Set based on field name
const nameFields = document.querySelectorAll('input[name*="name"]');
nameFields.forEach(input => {
input.autocapitalize = 'words';
});

The autocapitalize attribute:

  • Does not affect screen reader behavior
  • Is purely a keyboard input helper
  • Should be combined with proper labels and ARIA
<label for="fullName">Full Name</label>
<input
type="text"
id="fullName"
autocapitalize="words"
aria-required="true"
aria-describedby="nameHint">
<span id="nameHint">Enter your first and last name</span>

Users can still:

  • Override with Caps Lock
  • Type lowercase if desired
  • Use mobile keyboard’s shift key manually
<!-- Email type usually overrides autocapitalize -->
<input type="email" autocapitalize="words">
<!-- Browser likely ignores autocapitalize for email -->
<!-- Password type may ignore autocapitalize -->
<input type="password" autocapitalize="sentences">
<!-- Capitalization may not work -->
BrowserSupportNotes
iOS Safari5+Full support
Android ChromeAllFull support
Desktop ChromeIgnoredNo effect
Desktop FirefoxIgnoredNo effect
Desktop SafariIgnoredNo effect