Accessibility issue because labels and forms controls are not associated
-
Hi Aurovrata,
another report, sorry for keeping your busy.
I like to use CF7 because its easy to create an accessible form if done right. For that it is vital to have labels associated with a field, so in CF7 I would use the
<label>
element as a container:<label> Your name [text* your-name] </label>
(I could also use aria labels to build an association)
If I use https://wave.webaim.org/ to check the accessibility of a from created with your plugin I get “Missing form label” or “Select missing label” errors, depending on the form control. I am not an expert on web accessibility (far from it actually, I had to read this tutorial to figure out whats going on). Looking at the html structure the
<label>
element is not a container for the form control and there is no explicit association witharia-labelledby
.[...] <label>Test field<em>*</em></label> <span class="wpcf7-form-control-wrap test"> <select name="test" class="wpcf7-form-control wpcf7-select wpcf7-validates-as-required" aria-required="true" aria-invalid="false"> <option value="Test 1">Test 1</option> <option value="Test 2">Test 2</option> </select> </span> [...]
I am not sure if screen readers can successfully connect the label with the form controls, but I am sure it is not best practice.
I tried to manually change the HTML markup of a form from this
<div class="field textarea"><label>test field</label>[textarea x5 textarea-794]
to
<div class="field textarea"><label>test field[textarea x5 textarea-794]</label>
and it fixes the accessibility issues raised by the WebAIM tool, but I havent tested thoroughly. I can fix it manually for my forms but I think it would be great to have a accessible defaults for the Smart Grid plugin.
- The topic ‘Accessibility issue because labels and forms controls are not associated’ is closed to new replies.