Input Fields: Creating Accessible and User-Friendly Forms (WCAG 2.2)

WCAG stands for Web Content Accessibility Guidelines. It is a set of guidelines created by the World Wide Web Consortium (W3C) to ensure that web content is accessible to people with disabilities. WCAG provides a technical standard for creating accessible websites and digital content, and it covers a wide range of disabilities, including visual, auditory, physical, cognitive, and neurological disabilities.

WCAG is organized around four principles of accessibility: Perceivable, Operable, Understandable, and Robust (POUR). Each principle includes specific guidelines and success criteria that must be met in order for web content to be considered accessible.

The latest version of WCAG is WCAG 2.1, which was published in 2018. WCAG 2.1 includes several new guidelines and success criteria that address the needs of users with low vision, cognitive and learning disabilities, and users with disabilities on mobile devices. A draft version of WCAG 2.2 was published in November 2021 for public review and feedback. The new draft includes some new guidelines and success criteria that address the needs of users with cognitive and learning disabilities, users with low vision, and users with disabilities on mobile devices.

WCAG is widely recognized as the international standard for web accessibility, and many countries, including the United States and European Union, have adopted it as part of their accessibility regulations. Following WCAG guidelines can help ensure that your website or digital content is accessible to everyone, regardless of their abilities.

However, I can provide some general guidance on how to create an optimal input component that aligns with the current WCAG 2.2 standards.

Provide clear and concise labels

Every input field should have a label that describes the purpose of the field. The label should be visible and easy to understand. Additionally, ensure that the label is associated with the corresponding input element using the "for" attribute.

Use appropriate input types

Different input types (such as text, email, password, etc.) should be used based on the type of data that is being collected. This helps users understand what type of data is required and helps assistive technologies provide appropriate feedback.

Provide clear instructions and feedback

Instructions and feedback should be provided in a clear and concise manner. Users should be notified if their input is invalid, and the reasons for the error should be explained. Additionally, the input field should have appropriate error messaging and the user should be able to correct any mistakes they make.

Ensure keyboard accessibility

All input components should be accessible via keyboard navigation. This includes being able to access the input field, move between input fields, and submit the form using the keyboard.

Ensure compatibility with assistive technologies

Input components should be compatible with assistive technologies such as screen readers and keyboard-only navigation. This includes using appropriate ARIA (Accessible Rich Internet Applications) attributes to ensure that assistive technologies can properly communicate the purpose and function of the input field.

By following these guidelines, you can create an optimal input component that aligns with WCAG 2.2 standards and provides a good user experience for all users, regardless of their abilities or disabilities.

Here's an example of an HTML input component that follows the guidelines that were previously outlined in this article:

<label for="username">Username:</label>
<input type="text" id="username" name="username" aria-describedby="username-help" required>

<span id="username-help">Enter your username</span>

In this example:

  • The label "Username" is associated with the input field using the "for" attribute and the "id" attribute.
  • The "type" attribute is set to "text" to indicate that this is a text input field.
  • The "name" attribute is used to give the input field a name that can be used in form processing.
  • The "aria-describedby" attribute is used to associate the input field with the "username-help" span element, which provides additional instructions for the user.
  • The "required" attribute is used to indicate that this field is required and must be filled in before the form can be submitted.

The specific implementation of an input component will vary depending on the requirements of your website or application. But by following the guidelines I outlined earlier, you can create an input component that is accessible and easy to use for all users. In the use case above, we're not taking error messages into consideration. Presenting both error messages and help texts for an input field at the same time can be a bit tricky, as it's important to ensure that the user can easily differentiate between the two. Therefore, we will apply the following rule of thumb:

1. Use different styles

Use different styles or formatting to differentiate between the error message and the help text. For example, you could use a different font color or style for the help text, or place it in a separate box or section of the page.

2. Use clear language

Use language that clearly indicates whether the text is a help text or an error message. Avoid using similar-sounding phrases that could be confusing, such as "Please enter your name" (help text) and "Name is required" (error message).

3. Position the messages carefully

Position the help text and the error message in such a way that they are easy to see and don't overlap. For example, you could position the help text below the input field and the error message above it.

Use ARIA attributes: Use ARIA attributes like "aria-describedby" to associate the help text with the input field, and "role=alert" to indicate that an error message is present.

Here's an example of how to present both error messages and help texts for an input field:

<label for="name">Name:</label>
<input type="text" id="name" name="name" aria-describedby="name-help name-error" required>

<span id="name-help">Please enter your full name</span>
<span id="name-error" role="alert">Name is required</span>

  #name-help {
    color: #666;
    font-style: italic;
    font-size: 12px;

  #name-error {
    color: red;
    font-weight: bold;
    font-size: 14px;

In this example:

  • The help text and error message are associated with the input field using the "aria-describedby" attribute.
  • The help text is styled differently from the error message using CSS.
  • The "role=alert" attribute is used to indicate that the error message is an alert and should be announced by assistive technologies.

By following these best practices, you can present both error messages and help texts together in a way that is clear and easy to understand for all users.