I just wrote a little jQuery plugin to create custom checkboxes/radio buttons.

The approach is simple. Wrap a label around the input tags, then hide the input and style the label, thus having a minimal impact on the rest of the markup and no need to write weird event handlers to check/uncheck as the browser will take care of checking the field because of the label's implicit relationship with the .

There would be scenarios of course where people would already put their input inside of the label, so this plugin would create a nested label in those cases. I'm wondering if there are any adverse accessibility effects to having the labels nested like this.

And if anyone has any other accessibility issues they see, fee free to bring them up as well

It might not be an accessibility issue now but it could become one in the future because the above html fails the w3c validator if using a HTML4 Strict doctype.

AussieJohn
—
2012-07-05T00:16:17Z —
#3

kennard said:

It might not be an accessibility issue now but it could become one in the future because the above html fails the w3c validator if using a HTML4 Strict doctype.

Hmm this is a good point, the only way this would be valid is as XHTML, neither HTML4 or HTML5 allow nested label elements it seems. Perhaps I need to add some voodoo after all.

Mat30
—
2012-07-05T18:31:23Z —
#4

The problems here, if any exist, should show up quickly in testing. The biggest potential problem that I can see at a quick glance over your snippets is the absence of support for multiple labels per input. Almost no aural AT, other than JAWS (11 and later) with IE, supports more than one label per input, so they may well fail with your nested labels. Given that it is invalid to nest labels and, above all, feels like a really bad idea, I have never felt the need to test such a thing, but you ought to check carefully for the multiple label issue and similar problems because labels have to be handled with some care. It is quite easy to find their content being omitted from an accessibility API or two if bad practices are followed.

Mittineague
—
2014-09-25T05:55:49Z —
#5

This topic is now archived. It is frozen and cannot be changed in any way.