🚀 LEVEL UP TO SENIOR:Unlock 500+ Advanced Practical Challenges & Expert Masterclasses.
🎓 COURSERA PARTNER:Earn professional Google, Meta, and IBM certificates to supercharge your resume.
REFERENCEhtml

html Documentation

LOADING ENGINE...

HTML <legend> Tag

Create form group titles. Learn fieldset structure and form organization.

legend.html
<!-- Form Group -->
<form>
<fieldset>
<legend>Personal Information</legend>
<label for="name">Name:</label>
<input type="text" id="name">
</fieldset>
</form>
📜
legend.html
1 / 7
📜

Tutor:The <legend> tag defines a caption or title for a <fieldset> element. It's used to group related form elements and provide a descriptive label for the group. The legend appears at the top of the fieldset border.


Legend Mastery

Unlock nodes by learning fieldset and legend structure.

Concept 1: The Legend Tag

The <legend> tag defines a caption or title for a <fieldset> element. It's used to group related form elements and provide a descriptive label for the group. The legend appears at the top of the fieldset border.

System Check

Which element must contain a <legend> tag?


Community Holo-Net

Share Form Organization

Created well-organized forms with fieldset and legend? Share your code and best practices.

Enjoying this guide?

Codesyllabus is 100% free and open-source. Support our mission, pay for server infrastructure, and fuel new tutorials by buying us a coffee!

HTML <legend> Tag

Author

Pascual Vila

Frontend Instructor.

The <legend> tag defines a caption or title for a <fieldset> element. It's used to group related form elements and provide a descriptive label for the group. The legend appears at the top of the fieldset border.

Fieldset Structure

The <legend> tag must be placed as the first child of a <fieldset> element. It provides a semantic title for the grouped form controls. This improves accessibility and helps users understand the form structure.

Form Organization

Use fieldset and legend to organize complex forms into logical sections. For example, group contact information, shipping address, and payment details separately. This makes forms more accessible and easier to navigate.

Accessibility Benefits

The legend appears as a title within the fieldset border. Screen readers announce the legend when users navigate to the fieldset, improving accessibility for form navigation. This helps users understand which form elements belong together.

Best Practices

Always place the legend as the first child of the fieldset. Use descriptive text that clearly identifies the group of form elements. Use fieldset and legend for complex forms with multiple sections, not for simple single-field forms.

Legend Tag Glossary

<legend>
HTML element that defines a caption or title for a <fieldset> element. Must be placed as the first child of the fieldset.
<fieldset>
HTML element that groups related form elements together. The legend provides a title for this group.
First Child Requirement
The legend must be the first child element of the fieldset. This ensures proper semantic structure and accessibility.
Form Organization
Use fieldset and legend to organize complex forms into logical sections (e.g., contact info, shipping address, payment details). This improves accessibility and user experience.
Accessibility
Screen readers announce the legend when users navigate to the fieldset, helping users understand which form elements belong together. This improves form navigation for assistive technologies.