How do you create a basic HTML form?
A form wraps its fields in a <form> element, pairs each <input> with a <label>, and offers a <button> to submit — letting users enter data and send it off for processing.
Forms are how a web page becomes interactive: they let users choose options or type in data such as names, dates, and text, then send it on. A minimal one looks like this:
<form>
<label for="username">Username</label>
<input type="text" id="username">
<button>Submit</button>
</form>
The building blocks:
<form>— the container holding all the fields.<label>— a text description for a field.<input>— the actual data-entry control (here a single-line text box).<button>— a clickable button (typically wired up to submit the form).
The crucial detail is connecting each label to its input. You give the input a unique id and point the label's for attribute at that same id:
<label for="email">Email</label>
<input type="text" id="email">
This pairing is worth the effort: clicking the label then focuses the input (a bigger click target), and screen readers can announce which label belongs to which field — both important for accessibility.
Go deeper:
Web forms — MDN — full learning path from your first form through controls, structure, and validation.