When should I use required vs. aria-required?
Question
Answer
If a specific user input is required for a form submission, then the element should have a required or aria-required attribute. Which one to use depends on whether or not you're using a native element.
A native element is created using an html tag, such as <button>
, whereas a non-native element would use a role
attribute, such as role="button"
, to define the element.
For example, if you have a required first name input that is coded using <input>
, use required
. However, if you're using a non-native input, add an aria-required
attribute to the element.