Grouping Form Fields

Another means of making your forms more accessible is to group form information. You'll recall that in Chapter 4, “Creating Tables,” I showed you several ways to group table elements to make them more comprehensive. Well, the same concepts apply here, although different elements are used.

In the case of forms, you can break down areas of the form into specific sets of fields using the fieldset element. If you have a form with three contextual sections, such as Contact Information, Favorite Activities, and Reset or Submit, you can create fields around each of those. Then you can use the legend element to add a header for each of those sections, further providing context (see Example 5-14).

Example 5-14. Breaking forms ...

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.