Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Learn Grouping Form Elements for Better Structure | HTML Forms and User Input
Practice
Projects
Quizzes & Challenges
Quizzes
Challenges
/
Ultimate HTML

bookGrouping Form Elements for Better Structure

When form fields are related, grouping them helps users process information more easily. It breaks large forms into smaller, clear sections and improves usability. In HTML, grouping is done with <fieldset> and <legend>.

fieldset and legend Elements

  • <fieldset> groups related form controls;
  • <legend> adds a title for that group.

Useful for radio buttons, checkboxes, and any section of related fields.

index.html

index.html

index.css

index.css

copy

Example

This example uses the fieldset element to group related form controls together and the legend element to provide a caption for the group. It focuses on a product selection form where users can choose multiple products.

index.html

index.html

index.css

index.css

copy
  • The fieldset groups the checkboxes into one logical section;
  • The legend tells the user what the group is about;
  • Checkboxes allow selecting multiple items.
Note
Note

You've completed the final HTML step. If you want to continue growing your skills, your next step is CSS , where you'll learn how to style and design modern, attractive web pages.

1. What is the purpose of the legend element in HTML fieldsets?

2. Why is grouping related form elements with the fieldset element important?

question mark

What is the purpose of the legend element in HTML fieldsets?

Select the correct answer

question mark

Why is grouping related form elements with the fieldset element important?

Select the correct answer

Everything was clear?

How can we improve it?

Thanks for your feedback!

SectionΒ 5. ChapterΒ 10

Ask AI

expand

Ask AI

ChatGPT

Ask anything or try one of the suggested questions to begin our chat

Suggested prompts:

Can you show me a sample HTML form using fieldset and legend?

What are some best practices for using fieldset and legend in forms?

Are there accessibility benefits to using fieldset and legend?

bookGrouping Form Elements for Better Structure

Swipe to show menu

When form fields are related, grouping them helps users process information more easily. It breaks large forms into smaller, clear sections and improves usability. In HTML, grouping is done with <fieldset> and <legend>.

fieldset and legend Elements

  • <fieldset> groups related form controls;
  • <legend> adds a title for that group.

Useful for radio buttons, checkboxes, and any section of related fields.

index.html

index.html

index.css

index.css

copy

Example

This example uses the fieldset element to group related form controls together and the legend element to provide a caption for the group. It focuses on a product selection form where users can choose multiple products.

index.html

index.html

index.css

index.css

copy
  • The fieldset groups the checkboxes into one logical section;
  • The legend tells the user what the group is about;
  • Checkboxes allow selecting multiple items.
Note
Note

You've completed the final HTML step. If you want to continue growing your skills, your next step is CSS , where you'll learn how to style and design modern, attractive web pages.

1. What is the purpose of the legend element in HTML fieldsets?

2. Why is grouping related form elements with the fieldset element important?

question mark

What is the purpose of the legend element in HTML fieldsets?

Select the correct answer

question mark

Why is grouping related form elements with the fieldset element important?

Select the correct answer

Everything was clear?

How can we improve it?

Thanks for your feedback!

SectionΒ 5. ChapterΒ 10
some-alt