Skip to content
Guest
Learn HTML · Course Syllabus Show lessons
Forms & User Input · 10 min read · Beginner

Form Controls, Fieldsets & Constraint Validation

Go beyond basic text inputs with fieldset/legend, radio groups, select menus, datalist autocomplete, and native validation rules.

What you'll learn

  • Group related radio buttons or checkboxes with <fieldset> and <legend>
  • Offer choices using <select>, <optgroup>, and searchable <datalist>
  • Use inputmode, autocomplete, pattern, and min/max for frictionless UX

Great forms reduce typing effort and prevent mistakes before the user hits submit.

When you have a group of radio buttons (like “Preferred Track”), wrap them in <fieldset> with a <legend>. Screen readers automatically announce the legend before each radio option!

Choosing the Right Control

ControlBest For
<input type="radio">Choosing one option from 2–5 visible choices
<input type="checkbox">Toggling zero or more independent options
<select>Choosing one option from a long list (e.g., country)
<input list="..."> + <datalist>Free-text input with native autocomplete suggestions
<textarea>Multi-line comments or bio text

Fill-in-the-Blank Exercise

Accessible Radio Group

Group the radio choices accessibly using <fieldset> and <legend>.

<>
<>Experience Level</legend>
<label><input type="radio" name="level" value="beginner" /> Beginner</label>
<label><input type="radio" name="level" value="pro" /> Pro</label>
</fieldset>

Try It Yourself

Test the <fieldset>, <datalist> autocomplete, and numeric min/max validation below:

Rich Native Form Controls
Live Result
Console Output

No console output yet. Try calling console.log(...) in JS.

Check Your Understanding

Score: 0 / 1

1. How do radio buttons know they belong to the same mutually exclusive group?

Study Workspace

Finished this lesson?

Your progress is saved locally in your browser, no account needed.

Search courses, lessons, and references

Type to search across all courses, lessons, and quick references.

Press Esc to close Powered by Pagefind