Fix Form Fields That Lose Their Labels When Visitors Type
Keep a visible label next to every input and associate it with the input in HTML. Use a placeholder for an optional example such as a date format. The label should still identify the field after autofill or an error. 1. Start with the filled state Type into every input or use a test profile to exercise autofill. Ask which field is for a delivery phone and which is for a billing phone. In a hypothetical contact form with two numbers, a blank-field example can make both look identical once data is entered. Give each input a distinct visible name that includes the distinction readers use. 2. Inspect the relationship For a text input, a label with a matching for attribute and input id is a straightforward association. IDs must be unique across the actual page, including repeated components. Selecting the label should focus its input where that behavior applies. In the accessibility inspector, read the accessible name alongside any description. A date format or length requirement belon...