Labels: Why Every Input Needs One
A label does three things at once: it names the field for screen readers, enlarges the click target, and survives the field being filled in.
HTML is the easiest of these languages to write badly and still have something appear on screen, which is exactly why it is worth learning properly. These tutorials start from what a tag actually is and build up to markup that is readable, accessible and does not fall apart when you add CSS to it.
A label does three things at once: it names the field for screen readers, enlarges the click target, and survives the field being filled in.
Both controls submit nothing when unselected, which surprises people writing server code. Radio grouping is established by a shared name rather than by markup.
A select is right for long lists and wrong for short ones. The datalist element covers the case where a user might type something you did not anticipate.
The textarea is the one form control whose value is not set by an attribute, and that difference causes a specific and avoidable bug.
A button inside a form defaults to submitting it. That default is responsible for a lot of forms that submit when someone clicks something unrelated.
The browser can validate a form before it is sent, with no scripting at all. It is a usability feature and provides no security whatsoever.
Most forms are filled in on a phone. Two attributes decide which keyboard appears and whether the browser can fill the field automatically.
A group of radio buttons answers a question, and without a fieldset that question is never announced. It is the most commonly skipped element in form markup.
Placeholder-only forms look clean in a mockup and fail as soon as someone starts typing. The problems are well documented and easily avoided.
An error message in red text beside a field is invisible to a screen reader and to anyone who cannot distinguish the colour. Three attributes fix that.
A file input needs one attribute on the form to work at all, and omitting it produces a failure that gives no error message.
Everything in the browser is under the control of the person using it. Attributes can be deleted, hidden values edited, and requests sent without your form at all.