Projects Engine

fieldset

A fieldset is an HTML element used to group related elements within a form.

Home / Dictionary / fieldset

A fieldset is an HTML element used to group related elements within a form, providing a way to organize complex forms for better user experience and accessibility. The fieldset element is typically used in conjunction with the <legend> element, which provides a caption for the grouped elements. Here’s an example of how to use a fieldset:

<form>
  <fieldset>
    <legend>Personal Information</legend>
    <label for="name">Name:</label>
    <input type="text" id="name" name="name"><br><br>

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

  <fieldset>
    <legend>Address</legend>
    <label for="street">Street:</label>
    <input type="text" id="street" name="street"><br><br>

    <label for="city">City:</label>
    <input type="text" id="city" name="city"><br><br>

    <label for="zip">Zip Code:</label>
    <input type="text" id="zip" name="zip"><br><br>
  </fieldset>

  <input type="submit" value="Submit">
</form>

In this example, the form contains two fieldset elements, each with a legend to describe the grouped input fields. This helps to visually and semantically organize the form fields, making it easier for users to understand and fill out the form.