Grouping a few input fields

suggest change

While designing a form, you might like to group a few input fields together to help organise the form layout. This can be done with the <fieldset> element. Here is an example.

For each fieldset, you can set a caption for the group with the <legend> element.

Example

<form>
  <fieldset>
     <legend>1st field set:</legend>
     Field one:<br>
     <input type="text"><br>
     Field two:<br>
     <input type="text"><br>
  </fieldset><br>
  <fieldset>
     <legend>2nd field set:</legend>
     Field three:<br>
     <input type="text"><br>
     Field four:<br>
     <input type="text"><br>
  </fieldset><br>
  <input type="submit" value="Submit">
</form>

Result

Browser Support

Current versions of Chrome, IE, Edge, Firefox, Safari, and Opera support <fieldset> and <legend>.

Feedback about page:

Feedback:
Optional: your email if you want me to get back to you:



Table Of Contents