# Forms ## 1. Semantic Structure and Form Element ### Guidelines - **DO** use the `
` element to wrap interactive controls for data collection. - **DO** wrap search forms and filtering controls in a `` element. - **DO** give `` elements an accessible name via `aria-labelledby` (pointing to the form's heading) when a page has multiple forms. - **DO** use `method="POST"` for sensitive data and mutations; use `method="GET"` for idempotent requests (e.g., search). - **DO** specify the `action` attribute for the destination URL. - **DO** specify a `name` attribute for every form control to identify data on submission. - **DO** use semantic tags like ` ``` ## 10. Usability Testing and Analytics ### Guidelines - **DO** test forms across multiple devices, browsers, and screen sizes. - **DO** test keyboard-only navigation (using `Tab`, `Shift+Tab`, `Space`, `Enter`, and Arrow keys) and verify visual focus. - **DO** emulate various impairments (visual, motor) using browser tools. - **DO** use analytics to monitor form completion rates and bounce points. - **DO** track discrete events (e.g., field focus, click) to find micro-friction points. - **DON'T** rely solely on automated tools (Lighthouse) for usability; test with real users. - **DON'T** track sensitive personal data in standard event labels. ### Code Example ```html
``` ## 11. Multi-Page Forms ### Guidelines - **DO** clearly display progress through a multi-page form with clear labels and accessible progress indicators (e.g., `aria-current="step"` or ``). - **DO** allow users to navigate backwards and forwards between pages without losing previously entered data. - **DO** move focus to the new step's heading (`tabindex="-1"`) or first input when transitioning between steps dynamically without a full page reload. - **DO** use context-specific `enterkeyhint` values (e.g., `"previous"`, `"next"`) to guide navigation via on-screen keyboards. - **DO** design layouts so that the mobile keyboard does not obscure inputs or buttons (e.g., by placing them in the upper half of the viewport when focused or using CSS scroll-padding). - **DON'T** leave inactive wizard steps in the keyboard `Tab` order or accessibility tree (use `hidden`, `display: none`, or `inert` on non-active steps). ### Code Example ```html ```