HTML Guides for aria-invalid
Learn how to identify and fix common HTML validation errors flagged by the W3C Validator — so your pages are standards-compliant and render correctly across every browser. Also check our Accessibility Guides.
A span element cannot have role="text" because text is not a valid WAI-ARIA role.
The role attribute accepts only values defined in the WAI-ARIA specification. Common valid roles include button, alert, status, img, presentation, and many others, but text is not among them.
The non-standard role="text" was sometimes used as a workaround to prevent screen readers like VoiceOver from splitting inline elements into separate announcements. For example, when a span wraps mixed text and inline elements, some screen readers read each child element as a separate item. Using role="text" forced them to treat the content as a single text run. However, this was never part of the ARIA spec and causes a validation error.
If the goal is to group inline content so screen readers announce it as one continuous phrase, use role="group" with an aria-label that provides the full text. Alternatively, if the span has no semantic purpose, remove the role attribute entirely.
HTML examples
Invalid usage
<p>
<span role="text">
Sale price: <strong>$49.99</strong>
</span>
</p>
Valid alternatives
Remove the role if it serves no accessibility purpose:
<p>
<span>
Sale price: <strong>$49.99</strong>
</span>
</p>
Or use role="group" with aria-label to ensure screen readers announce the content as a single phrase:
<p>
<span role="group" aria-label="Sale price: $49.99">
Sale price: <strong>$49.99</strong>
</span>
</p>
The aria-invalid attribute belongs on the role="radiogroup" element that wraps the options, not on each role="radio" option inside it.
WAI-ARIA 1.2 deprecated aria-invalid as a global state, and future versions will only allow it on the roles that support it: application, checkbox, combobox, gridcell, listbox, radiogroup, slider, spinbutton, textbox and tree, plus the roles that inherit from them. radio isn't on that list. A radio button's validity depends on the whole group. A required choice is either made or missing, and no single option is wrong by itself.
Browsers and screen readers aren't required to expose a state on a role that doesn't support it, so an error set on the options may never reach the user.
The validator flags any element with an explicit role="radio" and an aria-invalid attribute, whatever its value, so aria-invalid="false" triggers the warning too. Native <input type="radio"> elements aren't flagged. To fix it, remove the attribute from every option and set it on the radiogroup container. Point aria-describedby on that container at the error message, so screen readers announce it along with the group's label.
Invalid example
<p id="plan-label">Choose a plan</p>
<div role="radiogroup" aria-labelledby="plan-label">
<div role="radio" aria-checked="false" aria-invalid="true" tabindex="0">Basic</div>
<div role="radio" aria-checked="false" aria-invalid="true" tabindex="-1">Pro</div>
</div>
<p id="plan-error">Select a plan to continue.</p>
Valid example
<p id="plan-label">Choose a plan</p>
<div role="radiogroup" aria-labelledby="plan-label" aria-invalid="true" aria-describedby="plan-error">
<div role="radio" aria-checked="false" tabindex="0">Basic</div>
<div role="radio" aria-checked="false" tabindex="-1">Pro</div>
</div>
<p id="plan-error">Select a plan to continue.</p>
Validate at scale.
Ship accessible websites, faster.
Automated HTML & accessibility validation for large sites. Check thousands of pages against WCAG guidelines and W3C standards in minutes, not days.
1K Weekly
1,000 monthly checks. Cancel anytime.
Get 1K Weekly →Join teams across 40+ countries