- Element of
- HTML Web Forms Tutorial For Coding Beginners
- What does
<legend> HTML Tagdo?
- The <legend> element is used to add a caption to a group of related form <input> elements that have been grouped together into a <fieldset>.
<form> <fieldset> <legend>Personal Information</legend> <label for="name">Name</label><br> <input name="name" id="name"><br> <label for="dob">Date of Birth<label><br> <input name="dob" id="dob" type="date"> </fieldset> </form>
Titles for Form Sections
<legend> element provides titles for form sections, providing a nice alternative to the
<h*> headline elements. They are designed to be used with the
<fieldset> element, and (strictly speaking) should only be used inside of one. Organizing form fields into
<fieldset> groups, with appropriate
<legend> captions can help make complicated forms more attractive and easier to use. For other tips on working with forms see our form design and form usability tutorials.
Browser Support for legend