Skip to main content

fieldset-missing-legend

Ensures that <fieldset> has a legend

Severity: Serious

Description

The rule checks that every <fieldset> has a <legend> properly describing its purpose.

A <fieldset> is used to group semantically common elements in an HTML form. It also helps in organizing the elements visually. A <legend> is typically the first child element of a <fieldset>. It describes or contextualizes the fieldset.

Why is it important?

Though the <legend> element is optional within a <fieldset>, if you want to improve the usability of forms, particularly for users who rely on screen readers or other assistive technologies, consider including it.
If the related form controls are clearly labeled and described, you can ignore this.

Example

Consider an HTM form that accepts name, email ID, and phone number as inputs. Each input falls under the common theme of personal information, which is the legend (description) of the fieldset (set of three fields, in this case).

HTML
Copy icon Copy snippet

Fieldset without legend

And here’s the complete code:

HTML
Copy icon Copy snippet

Fieldset with legend

How to fix?

Add a meaningful legend to the <fieldset>.

Reference

We're sorry to hear that. Please share your feedback so we can do better

Contact our Support team for immediate help while we work on improving our docs.

We're continuously improving our docs. We'd love to know what you liked






Thank you for your valuable feedback

Is this page helping you?

Yes
No

We're sorry to hear that. Please share your feedback so we can do better

Contact our Support team for immediate help while we work on improving our docs.

We're continuously improving our docs. We'd love to know what you liked






Thank you for your valuable feedback!

Talk to an Expert
Download Copy