webdevlinux - logo Web Dev Linux

Fieldset & legend

In this chapter, you will understand how to group contents of an HTML form with the fieldset element.

HTML fieldset legend Fieldset & Legend

Try the example below.

FILE : fieldset.html
<!DOCTYPE html>
<meta charset="utf-8" />
<legend>Login Form</legend>
Username : <input><br>
Password : <input type="password"><br>
<input type="submit"><input type="reset">


Take a look at the explanation of elements used in the example.

The fieldset element representsĀ a group inside the form
The legend element is used as a child element of fieldset. This represents the caption of the group (fieldset).