I'm trying to make a form accessible. Should I make my inputs have both required
and aria-required
attributes, or just one?
<label for="textbox1">Input</label> <input id="textbox1" type="text" name="Text Box" required>
Or like this?
<label for="textbox1">Input</label> <input id="textbox1" type="text" name="Text Box" aria-required="true">
Or like this?
<label for="textbox1">Input</label> <input id="textbox1" type="text" name="Text Box" aria-required="true" required>
The article Accessible HTML5 Forms – Required Inputs claims it is best to implement both.
When form controls are created using non-semantic elements, such as a <div> with a role of checkbox , the aria-required attribute should be included, with a value of true , to indicate to assistive technologies that user input is required on the element for the form to be submittable.
ARIA attributes can be used to make unsemantic HTML more accessible to screen reader users. For example, a developer who is struggling to style a native checkbox across multiple browsers might decide to use a div and some JavaScript to emulate one.
Definition and Usage The required attribute is a boolean attribute. When present, it specifies that an input field must be filled out before submitting the form. Note: The required attribute works with the following input types: text, search, url, tel, email, password, date pickers, number, checkbox, radio, and file.
ARIA is a set of attributes you can add to HTML elements that define ways to make web content and applications accessible to users with disabilities who use assistive technologies (AT). When accessibility issues cannot be managed with native HTML, ARIA can help bridge those gaps.
When John Foliot wrote that article in 2012 it was very much true. You needed both.
Today that is no longer the case. I can take your example, put it in a CodePen, and check it in JAWS and NVDA (sorry, no VoiceOver today):
<label for="textbox1">Input</label> <input id="textbox1" type="text" name="Text Box" required>
You will be happy to know that both NVDA and JAWS announce the field as required.
In short, you do not need aria-required
any longer. Just use required
.
You can read a bit more about the ARIA attributes you can dump in this article by Steve Faulkner (one of the editors of the ARIA spec) from 2015: http://html5doctor.com/on-html-belts-and-aria-braces/
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