• Hi everyone, I am having trouble associating labels to checkbox options. When I inspect html source code, label texts are wrapped in span elements under label elements, instead of directly wrapped inside label elements, which makes it difficult to comply with accessibility tests. Would someone know how to solve this?
    This is what I have in contact form 7:

    Have you travelled outside of the country in the last 14 days?</b>
    [checkbox* checkbox-c use_label_element exclusive "Yes" "No"]

    This is what I have in HTML code:

    <p><b>Have you travelled outside of the country in the last 14 days?</b><br />
    <span class="wpcf7-form-control-wrap checkbox-c"><span class="wpcf7-form-control wpcf7-checkbox wpcf7-validates-as-required wpcf7-exclusive-checkbox">
    <span class="wpcf7-list-item first">
    <label>
    <input type="checkbox" name="checkbox-c" value="Yes" />
    <span class="wpcf7-list-item-label">Yes
    </span>
    </label>
    </span>
    <span class="wpcf7-list-item last">
     <label><input type="checkbox" name="checkbox-c" value="No" /><span class="wpcf7-list-item-label">No</span></label></span></span></span></p>
    • This topic was modified 4 years, 1 month ago by helenhuang.
    • This topic was modified 4 years, 1 month ago by helenhuang.
Viewing 1 replies (of 1 total)
  • Plugin Author Takayuki Miyoshi

    (@takayukister)

    Wrapping an input field and its label text with a label element is valid as HTML.

    which makes it difficult to comply with accessibility tests

    Why do you think so? Do you have any particular issue with it?

Viewing 1 replies (of 1 total)
  • The topic ‘Checkbox labels’ is closed to new replies.