Reference · Beginner

HTML form elements

Collect user input with form, label, input, textarea, select, button, fieldset, and legend while preserving clear relationships.

Editorial preview — publication review is still required.

Author
Editorial team
Reviewer
Publication review pending
Review tier
180-day

Definition

Form elements define controls, labels, groups, and submission behavior for collecting input.

Minimal valid pattern

<form action="/subscribe" method="post">
  <label for="email">Email address</label>
  <input id="email" name="email" type="email" autocomplete="email" required />
  <button type="submit">Subscribe</button>
</form>

Key relationships

Every control needs a programmatic label. Related controls use fieldset and legend. The name identifies submitted data; type provides expected semantics and behavior.

Accessibility and security

Keep labels visible, errors specific, and focus predictable. Validate on the server, encode output, protect mutable endpoints from abuse, and do not claim a submission succeeds without a real endpoint.

Common misuse

Placeholders do not replace labels. A styled generic element does not replace a button. Client validation does not establish trust.