Loading…
Long forms can be confusing. HTML provides <fieldset> and <legend> to group related fields together with a visible label — like sections in a paper form.
<fieldset>
<legend>Personal Information</legend>
<label for="name">Name:</label>
<input type="text" id="name" name="name">
<label for="email">Email:</label>
<input type="email" id="email" name="email">
</fieldset>
| Element | Purpose |
|---|---|
<fieldset> | Groups related form fields and draws a border around them |
<legend> | The title of the group — appears in the top border |
Create a form with two fieldsets:
name="name")name="email")name="newsletter": "Yes" and "No"