WebAIM - Web Accessibility In Mind

E-mail List Archives

Re: Does WCAG require that when you click a label it checks the checkbox or radio button?

for

From: Karl Groves
Date: Nov 21, 2015 11:16AM


On Sat, Nov 21, 2015 at 2:02 AM, Chaals McCathie Nevile
< <EMAIL REMOVED> > wrote:

> In any event, given that browsers have fast, efficient, well-tested native
> code for making buttons work, why should we tell millions of authors to
> replicate that code in javascript? That is an inefficient, error-prone way
> to work. If browsers recognised controls from their role, why can't they
> just apply the same code they use when they recognise them from the element
> name? In the button case, I can't think of a reason. Nor in the case of a
> range control, or a date-picker.

If I understand what you're implying, I think you're proposing
something quite compelling, but likely difficult to make happen. Right
now, browser vendors have a well-defined DOM specification to work
from and gobs of legacy code implementing that. Keeping in mind that
a large portion of native form controls had their DOM interfaces
defined back in DOM Level 2.

Browsers already do some of this type of trickery using the Shadown
DOM for new HTML5 input types, so it isn't impossible. It just
seems... hairy. It seems difficult to now say "ok all objects with a
specified 'role' property should now apply the same DOM methods and
properties as those items they're pretending to be".

Imagine:
<input type="checkbox" role="heading" aria-labelledby="foo">
<label id="foo">I'm really a heading, trust me!</label>

Absurd? Yes. But there's no limit to developer silliness!


> The only issue will arise if the button is
> coded to do something the user *doesn't* expect, like operate on pressing q
> or f.

Well that, like anything, comes down to the designers & developers
disavowing themselves of any misguided belief that doing so would be a
good idea. ;-)


--

Karl Groves
www.karlgroves.com
@karlgroves
http://www.linkedin.com/in/karlgroves
Phone: +1 410.541.6829

Modern Web Toolsets and Accessibility
https://www.youtube.com/watch?v=_uq6Db47-Ks

www.tenon.io