label
Connects human-readable text to a control.
Learn Form Elements with practical examples for form structure, input behavior, validation, autocomplete, accessibility, backend safety and live practice.
HTML forms
HTML forms are built from a small set of controls: input, textarea, select, option, button, label, fieldset, legend, datalist, output and more.
Each element has a job. Textarea is for longer text. Select is for a controlled list. Fieldset groups related controls. Legend names that group.
Choosing the right form element reduces custom code and gives users native browser behavior for free.
Connects human-readable text to a control.
The most flexible single-line control.
A multi-line text control for longer messages.
Groups related controls under one legend.
Syntax and behavior
Do not force every answer into a text input. Browsers already provide controls for options, choices, dates, files and long text.
<form action="/signup" method="post">
<label for="goal">Goal</label>
<select id="goal" name="goal">
<option value="regular">Regular course</option>
<option value="fast">Fast track</option>
</select>
<label for="message">Extra information</label>
<textarea id="message" name="message"></textarea>
<button type="submit">Request access</button>
</form>
<input name="goal" placeholder="Type regular or fast"> <input name="message" placeholder="Type your full message here"> <span onclick="send()">Send</span>
Rules that matter
Strong form markup is readable, accessible, secure by design and easy to connect to real server-side validation.
A message box should not be a cramped single-line input.
If only a few valid options exist, do not ask users to guess the text.
Radio buttons and checkbox groups become clearer with fieldset and legend.
Buttons are keyboard-friendly and have native behavior.
Visible labels help users scan, correct and complete the form.
Native controls are often more robust than hand-built replacements.
Production thinking
This matters because the right element makes the form easier before any styling or JavaScript is added.
Fieldset and legend are especially useful for grouped radio buttons and checkboxes because they announce the question before the options.
Design systems should style native controls carefully without destroying focus states, labels or keyboard behavior.
Useful form labels and supporting text improve page quality and help users understand the purpose of a service page.
Live code lab
Edit the HTML or CSS, then use Run to refresh the preview. The preview is isolated, so links and forms stay inside this practice area.
Mini assignment
Practice assignment
Try it yourself
Self-check
Do not only read this page. Answer these questions out loud or write the answers in your own notes. If one answer feels vague, revisit the examples before moving on.