I'm using the axe Chrome extension to check for accessibility and I am receiving a violation on my radio buttons and check boxes. Looking at the W3C documentation for "aria-required", you can find it here: W3C on aria-required, neither input is listed for the used roles.
According to this question: HTML5: How to use the “required” attribute with a “radio” input field, you just need to mark one radio button with required. However, I am trying to use aria with older browsers and I get a violation Elements must only use allowed ARIA attributes saying that "aria-required" is not allowed on any of my inputs of type radio or checkbox with aria-required.
Is this a discrepancy with the tool, does the HTML5 required work slightly different, or is aria-required actually not allowed on radios or checkboxes?
Over-using it. If the element has text content, you DON'T need to add aria-label , as it is redundant.
The aria-required attribute indicates that user input is required on the element before a form may be submitted.
Because the attribute “aria-required” is supported by commonly used browser-assistive technology combinations, many consider its use as the easiest and most optimal method for indicating that input is required for a field.
Checkboxes allow the user to choose items from a fixed number of alternatives, while radio buttons allow the user to choose exactly one item from a list of several predefined alternatives.
As indicated in the wai-aria documentation aria-required
can be used on radiogroup elements.
You can set a fieldset
(with the corresponding aria-required
attribute).
<fieldset aria-required="true">
<legend>Do you like ARIA? (mandatory question)</legend>
<input type="radio" name="answer" required="required" value="Yes"/>
<input type="radio" name="answer" required="required" value="No"/>
</fieldset>
Note that you have to set both the aria-required
and required
attributes and explicitely indicate that this field is mandatory.
You could also have used a <div role=radiogroup>
if you weren't using proper HTML inputs (see comment below)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With