Course contentsShow
← Web Development
Lesson 924 of 2,98216. Forms and ValidationFree lesson

Required Field Indicators

Marking required fields with aria-required, visual indicators, and ensuring screen readers announce required status.

Required Field Indicators

What you'll learn: How to properly mark and communicate required form fields to all users, including those using assistive technologies.

Why Required Indicators Matter

When a form field is mandatory, every user needs to know before they try to submit. Sighted users might see a visual asterisk or "required" label, but screen reader users need equivalent information delivered through their assistive technology. Required field indicators bridge this accessibility gap.

Three Essential Components

1. The aria-required Attribute

Add aria-required="true" to your input elements to explicitly tell screen readers this field is mandatory:

<input type="text" id="username" aria-required="true">

When a screen reader encounters this field, it will announce something like "Username, required, edit text."

2. Visual Indicators

Provide a visual cue that sighted users can recognize instantly:

<label for="email">
  Email <span class="required-indicator">*</span>
</label>
<input type="email" id="email" required aria-required="true">

Common visual patterns include asterisks (*), colored text, or the word "(required)".

3. The required Attribute

The native HTML required attribute triggers browser validation and is announced by many modern screen readers. Always pair it with aria-required="true" for maximum compatibility:

<input type="text" id="name" required aria-required="true">

Best Practice Pattern

Combine all three for comprehensive accessibility:

<label for="phone">
  Phone Number <span aria-hidden="true">*</span>
</label>
<input type="tel" id="phone" required aria-required="true">

Note: Use aria-hidden="true" on the asterisk to prevent screen readers from announcing it as "star" or "asterisk" when they already announce "required."

Key Takeaway: Required field indicators need both visual cues for sighted users and semantic markup (required and aria-required) for screen reader users—always implement both to ensure all users understand which fields are mandatory.