Trusted answers to developer questions
Trusted Answers to Developer Questions

Related Tags

html5
communitycreator

HTML <legend> tag

Shubham Singh Kshatriya

The <legend> tag in HTML is used to define the caption or the title for it’s parent <fieldset> element. It is the first child of the <fieldset>.

Syntax

<legend>
  // some title
</legend>

Example

In this example, we will see how we can use a <legend> element to add a title to the <fieldset> element.

Explanation

In the first fieldset, we are asking the user to enter the address and contact number. Then we set the title to Delivery details using the legend tag in line 3. Similarly, in the second fieldset where we are asking the user for Card holder name, Expiry date, and CVV number, we set the title to Payment details using the legend tag in line 12.

Supported Browsers

  • Google Chrome
  • Internet Explorer
  • Firefox
  • Opera
  • Safari

RELATED TAGS

html5
communitycreator

CONTRIBUTOR

Shubham Singh Kshatriya
RELATED COURSES

View all Courses

Keep Exploring