Search code examples
htmllabelsection508

form label 508 compliance question


Do labels that I create for my form elements need to be in the <form> body? for example would this be compliant:

<div style="display: none;">
    <label for="somename">Some Name</label>
    <!-- more labels.. //-->
</div>

<!-- insert lots of HTML here //-->

<form>
<input type="text" name="somename" id="somename">
<!-- insert more elems here //-->
</form>

Solution

  • In general, the tag doesn't really provide much semantic meaning unless you happen to have more than 1 form on a page, in which case the form tag indicates what form elements it is associated with.

    That being said, tags also do not depend on their location because they are tied to 1 and only 1 other element by that element's ID, so no, it doesn't matter where you put it in relation to the element it is a label for, but it is usually good practice to keep the label near the element. I would question the semantic validity of your page if it drifts too far from the element it describes, and making sure your document is semantic is a key component of being accessible. 508 does only require a best-effort for accessibility, but few and far between are the cases where having a semantic document is too hard to do.