HTML autocapitalize Attribute

Beginner
⏱️ 5 min read
📚 Updated: Jun 2026
🎯 3 Examples
Forms & Input

Introduction

The autocapitalize attribute is a useful feature in HTML that allows developers to control the capitalization behavior of text inputs. This attribute is particularly beneficial for enhancing user experience by ensuring text inputs are automatically capitalized according to specified rules, which can be especially helpful for mobile and touchscreen devices.

What You’ll Learn

01

none

No auto caps.

02

sentences

First letter each sentence.

03

words

Capitalize each word.

04

characters

All uppercase.

05

Mobile UX

Virtual keyboards.

06

JavaScript

Set dynamically.

Purpose of autocapitalize Attribute

The primary purpose of the autocapitalize attribute is to manage how text entered into an input field is capitalized. This attribute can be applied to <input> and <textarea> elements, ensuring consistent text formatting hints for virtual keyboards without requiring additional user effort.

📱
Mobile-Focused

autocapitalize mainly affects iOS and Android virtual keyboards. It does not transform text after it is entered—it hints how the keyboard should behave.

📝 Syntax

Add autocapitalize to an <input> or <textarea> with a keyword value:

autocapitalize.html
<input type="text" autocapitalize="words">

Syntax Rules

  • Used on text-editable form controls: input and textarea.
  • Value is a keyword: none, sentences, words, or characters.
  • Does not change stored value—only keyboard capitalization behavior.
  • Often combined with appropriate type (e.g. type="email" with autocapitalize="none").

💎 Values

The autocapitalize attribute accepts several values, each defining a different capitalization behavior:

  • none — No automatic capitalization. All characters are input as typed by the user.
  • sentences — Capitalizes the first character of each sentence. Useful for bios and paragraphs.
  • words — Capitalizes the first character of each word. Ideal for names and titles.
  • characters — Capitalizes all characters. Useful for access codes and acronyms.
autocapitalize-values.html
<input autocapitalize="none">
<input autocapitalize="sentences">
<input autocapitalize="words">
<input autocapitalize="characters">

⚡ Quick Reference

Field TypeSuggested ValueWhy
Full namewordsCapitalize each name part
Bio / commentsentencesNormal sentence case
Access code / SKUcharactersAll caps entry
Email / usernamenoneAvoid unwanted caps
Applicable elementsinput, textareaText entry fields

Applicable Elements

ElementSupported?Notes
<input type="text">YesPrimary use case
<textarea>YesMulti-line text
<input type="email">YesOften use none
<select>No practical effectNot a text entry control

Examples Gallery

Form with multiple values, dynamic JavaScript, and none for email fields.

👀 Live Preview

Three fields with different autocapitalize values:

Test on a phone or tablet to see keyboard capitalization differences.

Implementation Example

Here’s an example of how to use the autocapitalize attribute in an HTML form:

index.html
<form>
  <label for="name">Name:</label>
  <input type="text" id="name" name="name" autocapitalize="words">

  <label for="bio">Bio:</label>
  <textarea id="bio" name="bio" autocapitalize="sentences"></textarea>

  <label for="code">Access Code:</label>
  <input type="text" id="code" name="code" autocapitalize="characters">

  <input type="submit" value="Submit">
</form>
Try It Yourself

How It Works

In this example, the autocapitalize attribute is set to words for the name input field, sentences for the bio textarea, and characters for the access code input field.

Dynamic Values with JavaScript

You can also dynamically set the autocapitalize attribute using JavaScript. This can be useful when you want to change the capitalization behavior based on certain conditions or user interactions. Here’s a brief example:

dynamic-autocapitalize.html
<input type="text" id="dynamicField">

<script>
  document.getElementById("dynamicField").setAttribute("autocapitalize", "words");
</script>
Try It Yourself

How It Works

In this script, the autocapitalize attribute is set to words for an input field with the id dynamicField. This can be helpful when dynamically changing input field properties based on the application’s logic.

Example — autocapitalize="none"

Disable automatic capitalization for fields where caps would be wrong:

none-autocapitalize.html
<input type="email" autocapitalize="none" placeholder="user@example.com">
Try It Yourself

How It Works

none tells the virtual keyboard not to auto-capitalize. This is ideal for email addresses, usernames, and URLs.

♿ Accessibility

  • Reduce typing friction — Proper capitalization hints help users enter names and sentences faster on mobile.
  • Do not rely on it for validation — Users can still enter lowercase text; validate on the server if case matters.
  • Pair with clear labels — Tell users what format is expected (e.g. “Access code in uppercase”).
  • Use none for technical fields — Email and code fields should not force sentence case.

🧠 How autocapitalize Works

1

Author sets autocapitalize

Choose none, sentences, words, or characters.

Markup
2

User focuses the field

Virtual keyboard reads the capitalization hint.

Mobile
3

Keyboard adjusts shift behavior

Caps apply as the user types each character or word.

Input
=

Smoother mobile form entry

Users type names, sentences, and codes with less manual shifting.

Browser Support

The autocapitalize attribute is supported on mobile browsers (iOS Safari, Chrome for Android). Desktop browsers may ignore it because physical keyboards do not use the hint.

📱 Mobile · Primary support

Virtual keyboard attribute

iOS and Android honor autocapitalize on text fields. Desktop support is limited.

90% Mobile support
iOS Safari Fully supported
Full support
Chrome (Android) Fully supported
Full support
Firefox Mobile Supported
Supported
Desktop browsers Limited effect
Partial
autocapitalize attribute Best on mobile

Bottom line: Use autocapitalize for mobile-friendly forms; test on real devices.

💡 Best Practices

✅ Do

  • Use words for names and titles
  • Use sentences for bios and comments
  • Use characters for codes and acronyms
  • Use none for email and username fields
  • Test forms on iOS and Android devices

❌ Don’t

  • Expect desktop keyboards to change behavior
  • Use characters on regular name fields
  • Rely on autocapitalize for data validation
  • Apply to <select> expecting text caps
  • Forget that users can override keyboard caps manually

Conclusion

The autocapitalize attribute is a powerful tool for managing text capitalization in HTML forms. By understanding and using this attribute appropriately, you can improve the usability and readability of your web forms, providing a better experience for your users.

Match each field’s value to the kind of text you expect, and always test on mobile where the effect matters most.

Key Takeaways

Knowledge Unlocked

Five truths every developer should know about autocapitalize

Bookmark these before building mobile forms.

5
Core concepts
📱 02

Mobile First

Virtual keyboards.

Platform
📄 03

input & textarea

Text fields only.

Scope
⚙️ 04

JavaScript

setAttribute()

Dynamic
05

Keyboard Hint

Not validation.

Behavior

❓ Frequently Asked Questions

It hints to the virtual keyboard how to capitalize text as the user types.
input and textarea elements used for text entry.
none, sentences, words, and characters.
Mostly no. Effects are strongest on iOS and Android virtual keyboards.
Yes. Use element.setAttribute("autocapitalize", "words") at runtime.
No. It only affects keyboard behavior. Users can still type any case.

Build mobile-friendly forms

Practice the autocapitalize attribute with name, bio, and code fields in the Try It editor.

Try form example →

About the author

Mari Selvan M P
Mari Selvan M P 🔗

Developer, cloud engineer, and technical writer

  • Experience 12 years building web and cloud systems
  • Focus Full Stack Development, AWS, and Developer Education

I write practical tutorials so students and working developers can learn by doing—from databases and APIs to deployment on AWS.

5 people found this page helpful