Command Palette

Search for a command to run...

Hectal
Back to the lesson: Topic 4.3 — Labels, Fieldsets and Legends
HTML · Example 2 of 2

A fieldset switches a whole group off

The inputs inherit "disabled" from their fieldset, even though their own disabled property stays false.

A <label> ties visible text to a control so everyone knows what it's for and can click the text to use it; a <fieldset> with a <legend> groups related controls under one shared caption.

Change the code and press Run (Ctrl+Enter). Predict what will happen first, then break it on purpose and read what changes. Your edits are saved and match the lesson page.

Ready for more? This phase has 5 hands-on exercises with automatic checks.

Practice questions

Write the code in the editor, run it, then open the model answer to compare.

01

Write a login form with properly labelled username and password fields, using for/id.

02

Group two radio-style questions: a fieldset with the legend Contact me by, containing labelled checkboxes for Email and SMS.

Explain it without notes

01

What are the two ways to connect a label to a control, and what does each need?

02

Why do labels matter for accessibility and for usability?

03

When should you use a fieldset and legend?

04

What does disabled on a fieldset do?

A fieldset switches a whole group off

Preview

Press Run to see the page.

Console

Nothing logged yet.

Expected console output

Before: [ 'name', 'street', 'city' ]
After disabling the fieldset: [ 'name' ]
city.disabled: false but matches :disabled? true
Controls in the fieldset: 2