Making Forms More Accessible with labelto do with form controls, which are components built into browsers and invoked by the corresponding HTML. The label element allows information to be attached to a given control. Using this along with the for attribute enables you to describe the form control being used in more detail (see Example 5-13). Example 5-13. Adding context using the label element<form method="get" action="http://www.myserver.com/cgi-bin/mailscript/"> <label for="firstname">First Name:</label><input type="text" name="firstname" You'll recall that earlier I mentioned that the use of the id attribute within the input was an important part of accessibility, and here you see why. NOTE You'll notice that the label always comes before the control it's describing. In every case in which you are labeling a form control, the value of the for attribute must match the exact value of the id attribute within the control itself. This enables screen readers to provide more descriptive information about the control. |
| |||||||||||||||||||