Making Forms More Accessible with label

By their very interactive nature, forms are a bit more demanding in the accessibility department than other HTML elements. This is largely because all the items we've been discussing in this chapter have to do with form controls, which are components built into browsers and invoked by the corresponding HTML.

For a visual person, all this makes sense. But for individuals who are having the form read to them instead of seeing it, context can be quickly lost.

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

Get Spring Into HTML and CSS now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.