The HTML <legend> tag is used for providing a title or explanatory caption for the rest of the contents of the legend element's parent element, usually it defines a caption for a fieldset. The element must appear directly after the opening fieldset tag.

The <legend> element can be used in conjuction with the <fieldset>, <##_tag-figure_##>, and <##_tag-details_##> elements.

By using the <legend> tag, you can make your forms and other elements much easier to understand for your users.

Required Attributes

  • None.

Optional Attributes

  • accesskey can be used to associate a keyboard shortcut to the element.
  • Common attributes

Example

<fieldset>
	<legend> Address </legend>
	<label>Address Line 1</label>
	<input name="adressLine1" />
</fieldset>

Changes in HTML5

  • None.

Related Tags