The HTML form Element: action and method
A form is the oldest interactive feature in HTML and works entirely without JavaScript. Understanding what submission actually does explains most form problems.
Inputs, labels, validation and what actually happens when a form is submitted.
A form is the oldest interactive feature in HTML and works entirely without JavaScript. Understanding what submission actually does explains most form problems.
The choice between the two methods is not about size or preference. It comes down to whether the request reads something or changes something.
The type attribute changes the keyboard on a phone, the validation applied, and the interface offered. Two of the types are best avoided.
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.