Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

When to use the disabled attribute vs the aria-disabled attribute for HTML elements?

I'm trying to make a form accessible. Should I make my inputs have both disabled and aria-disabled attributes, or just one?

<label for="textbox1">Input</label> <input id="textbox1" type="text" name="Text Box" disabled> 

Or like this?

<label for="textbox1">Input</label> <input id="textbox1" type="text" name="Text Box" aria-disabled="true"> 

Or like this?

<label for="textbox1">Input</label> <input id="textbox1" type="text" name="Text Box" aria-disabled="true" disabled> 
like image 990
Ralph David Abernathy Avatar asked Jun 27 '16 16:06

Ralph David Abernathy


People also ask

What are aria attributes and when would you need to use them?

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.

Why do we use aria in HTML?

Semantic HTML and Accessible Rich Internet Applications (ARIA) help create interfaces that work for everyone in the most performant, robust, and simple way possible. They add essential meaning to your content, which lets web browsers, search engines, screen readers, RSS readers, and ultimately users understand it.

What are the three types of aria attributes?

ARIA States & PropertiesWidget attributes. Live region attributes. Drag-and-drop attributes.

What HTML elements can be disabled?

The disabled attribute is supported by <button> , <command> , <fieldset> , <keygen> , <optgroup> , <option> , <select> , <textarea> and <input> . This Boolean disabled attribute indicates that the user cannot interact with the control or its descendant controls.


2 Answers

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" disabled> 

You will be happy to know that both NVDA and JAWS skip the field (or if explicitly focused, announce that is disabled).

In short, you do not need aria-disabled any longer. Just use disabled.

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 (though aria-disabled is not explicitly listed, the concept is the same): http://html5doctor.com/on-html-belts-and-aria-braces/

If my answer looks similar to your other question about required versus aria-required, that is because it is essentially the same answer.

like image 132
aardrian Avatar answered Oct 12 '22 16:10

aardrian


An important distinction is that when using voice-over the item with just the 'disabled' property will not be tabbed to. However the item with aria-disabled="true" will still be able to receive focus and report to the screen reader as dimmed.

like image 30
brandonbradley Avatar answered Oct 12 '22 16:10

brandonbradley