Skip to content
techsnow

HTML Forms

Fieldset and Legend

<fieldset> groups related inputs, and <legend> gives the group a title. Browsers draw a border around the group.

<form>
  <fieldset>
    <legend>Personal details</legend>
    <label>Name <input name="name"></label>
    <label>Email <input type="email" name="email"></label>
  </fieldset>

  <fieldset>
    <legend>Payment method</legend>
    <label><input type="radio" name="pay" value="card"> Card</label>
    <label><input type="radio" name="pay" value="cod"> Cash on delivery</label>
  </fieldset>
</form>