HTML Tags

HTML <fieldset> Tag

The <fieldset> tag is used to group related elements in a form.
It helps organize form controls visually and semantically, often improving usability and accessibility.
It is usually combined with the <legend> tag to provide a caption for the grouped fields.

Syntax

<fieldset>
  <legend>Group Name</legend>
  <!-- Form elements go here -->
</fieldset>

Attributes

AttributeDescription
disabledDisables all form controls within the fieldset.
formAssociates the fieldset with a specific form (useful if outside the form).
nameSpecifies the name of the fieldset (rarely used).
idAssigns a unique ID to the fieldset.

Example

<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Fieldset Example</title>
</head>
<body>
  <h2>Registration Form</h2>
  <form action="/samples/form_processor.php" method="post">
    <fieldset>
      <legend>Personal Information</legend>
      <label for="fname">First Name:</label>
      <input type="text" id="fname" name="fname" required><br><br>

      <label for="lname">Last Name:</label>
      <input type="text" id="lname" name="lname" required><br><br>

      <label for="email">Email:</label>
      <input type="email" id="email" name="email" required>
    </fieldset><br>

    <fieldset>
      <legend>Account Details</legend>
      <label for="username">Username:</label>
      <input type="text" id="username" name="username" required><br><br>

      <label for="password">Password:</label>
      <input type="password" id="password" name="password" required>
    </fieldset><br>

    <input type="submit" value="Register">
  </form>
</body>
</html>

Output

Browser Output

You will see two distinct sections in the form, each surrounded by a box with a legend at the top.
The first box is “Personal Information,” and the second is “Account Details.”
Try it in our TryIt Editor to see the visual grouping and how it improves form readability.

Browser Support

Chrome
Chrome
Firefox
Firefox
Edge
Edge
Safari
Safari
Opera
Opera
IE
IE9+
✅Yes✅Yes✅Yes✅Yes✅Yes✅Yes

All major browser supports <fieldset> tag.

Notes

  • <fieldset> visually groups form fields and improves form semantics.
  • Combine with <legend> for a caption describing the group.
  • disabled can disable all fields in the group.
  • Useful for long or complex forms to make them more readable.

Conclusion

The <fieldset> tag is ideal for grouping related form elements, making forms more organized and user-friendly.
It enhances visual clarity and accessibility for users and assistive technologies.

Sign In Form

User your email and password to singn in

Don’t have an account, signup here : 

HTML5 & CSS3

Tools and Tutorials

Want a Website

Want a website for your business ?

Please fill out the details below, so we can reach out to you.

Registration Form

Signup to track your record and much more.

We have sent you an email with a registration link. Please click the link to verify your email address, or enter the 6-digit OTP provided in the email.

Didn't receive the OTP. Regenerate OTP Resend