You might see <fieldset> Element reference while reading someone else’s HTML, or need it while building a page of your own. Instead of memorizing a definition, look at a working example and see when the element makes sense.
The Idea in Plain English
Groups related form controls under one shared question. Pair it with legend, especially for radio-button groups.
For a reference page, pay attention to where the element is allowed, whether it needs a closing tag, and what other elements it can contain.
A Working Example
Read the sample once before copying it. Notice the element names and attribute values, then compare them with the explanation below.
<fieldset>
<legend>Choose a meeting day</legend>
<label><input type="radio" name="day" value="monday"> Monday</label>
<label><input type="radio" name="day" value="friday"> Friday</label>
</fieldset>
What Each Part Does
- A fieldset groups controls that answer one related question.
- A legend states the question shared by a fieldset.
- The label tells visitors and assistive tools what a control is for.
- type chooses the relevant kind of script, input, media or embedded object.
- name identifies a field in submitted form data or a named metadata entry.
- value specifies a form value or a machine-readable value.
Screen readers can announce the group question with each option.
Try It Yourself
Try replacing the example content with your own while keeping the valid HTML structure.
Common Beginner Mistakes
- Leaving a radio group without a shared explanatory legend.
- Changing several parts of the example at once, making it difficult to see which part caused a different result.
- Choosing a tag only because its default appearance looks right, without checking whether it describes the content correctly.
Key Takeaways
- Groups related form controls under one shared question. Pair it with legend, especially for radio-button groups.
- Screen readers can announce the group question with each option.
- Test the markup in a browser, and check accessibility and real-world behavior where relevant.