Implement programmatic input purpose for form accessibility
To comply with WCAG 1.3.5, input fields that collect information about the user must be programmatically determinable. Providing only a <label> or a generic type attribute (like type="text") is insufficient. You must use the autocomplete attribute with a valid token to allow browsers and assistive technologies to provide autofill and custom iconography.
Key Constraints:
- Use the
autocompleteattribute specifically for the user's own personal information. - Do not use
autocompletefor fields collecting information about other people (e.g., guest email addresses in an invitation form). - Use kebab-case values (e.g.,
family-name) rather than camelCase (e.g.,familyName).
<!-- Correct Implementation -->
<label for="first-name">First Name</label>
<input autocomplete="given-name" type="text" id="first-name">
<label for="last-name">Last Name</label>
<input autocomplete="family-name" type="text" id="last-name">