CKTIS / HTML
autocapitalize: a capitalization hint
Guide a text input method without mistaking a keyboard hint for validation.
Version: HTML Living Standard
Syntax
<input autocapitalize="characters" pattern="[A-Z]+">The global attribute autocapitalize suggests capitalization for text entry: none and off disable it, sentences and on suggest sentence starts, while words and characters suggest word starts and all letters. A control without its own setting can inherit the hint from its form. The input method may ignore or override the hint; URL, email and password inputs do not use it to force capitalization.
This is not a transformation of stored text. A physical keyboard, pasted content or a value assigned by script must not be assumed to become uppercase. Use pattern for a suitable browser validity check and validate on the server too. Changing letter case also requires an explicit product decision: names and passwords must not be normalized blindly.
The example assigns lowercase text to a field requesting uppercase input. It fails the pattern until the script deliberately converts it. This proves the separation between a hint, a value and validation; it does not test the layout or behavior of a real phone keyboard.
Examples
<!doctype html><meta charset="utf-8">
<label>Code <input id="code" autocapitalize="characters" pattern="[A-Z]+"></label>
<output id="result"></output><script>
const field = document.querySelector('#code');
field.value = 'abc';
const beforeValid = field.checkValidity();
// Explicit application logic, not an automatic effect of autocapitalize.
field.value = field.value.toUpperCase();
document.querySelector('#result').textContent = 'hint=' + field.autocapitalize + '; beforeValid=' + beforeValid + '; afterValid=' + field.checkValidity() + '; value=' + field.value;
</script>Result
hint=characters; beforeValid=false; afterValid=true; value=ABC
The result changes because the application explicitly converts the string, not because the capitalization attribute rewrites it.