Skip to content

aria-required not necessary when native required present#1238

Merged
mschwemer merged 1 commit intoin2code-de:typo3-v12from
MohsinQK:typo3-v12
Mar 13, 2026
Merged

aria-required not necessary when native required present#1238
mschwemer merged 1 commit intoin2code-de:typo3-v12from
MohsinQK:typo3-v12

Conversation

@MohsinQK
Copy link
Contributor

Accessibility Note: Use of required vs aria-required (WCAG 2.1)

According to WCAG 2.1, it's important to use the correct attribute to indicate that a form field is required for assistive technologies. Here’s a breakdown of best practices:


required (HTML5 native attribute)

  • Should be used on native form elements like <input>, <select>, and <textarea>.
  • Recognized by modern browsers and assistive technologies (e.g., screen readers).
  • Triggers built-in form validation and provides sufficient accessibility information.
  • No need to add aria-required="true" if required is already present on native elements.

aria-required="true"

  • Used only for custom form controls (e.g., a <div> with role="textbox").
  • Ensures that assistive technologies know the field is required when native HTML validation is not available.
  • Does not trigger browser-native form validation.

🔧 Best Practice

  • Use required for all native HTML5 form elements.
  • Use aria-required="true" only when building custom form components.
  • Avoid adding both required and aria-required="true" to the same native element – it’s redundant.

📘 WCAG 2.1 References

@Teisi
Copy link
Contributor

Teisi commented Jun 3, 2025

#293

@deoostfrees deoostfrees self-requested a review September 17, 2025 17:06
@mschwemer
Copy link
Collaborator

See also #1229

Copy link
Member

@deoostfrees deoostfrees left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

aria-required="true" was included in the codebase as a fallback for older screen readers that did not reliably display the required state of the native required attribute. However, since modern assistive technologies (NVDA, JAWS, and VoiceOver) now handle this correctly, it is no longer necessary for native HTML form elements.

@mschwemer mschwemer merged commit 66aadb9 into in2code-de:typo3-v12 Mar 13, 2026
mschwemer pushed a commit that referenced this pull request Mar 13, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants