Please note, this is a STATIC archive of website from 10 Sep 2022, does not collect or store any user information, there is no "phishing" involved.

HTML <legend> Tag

Topic: HTML5 Tags ReferencePrev|Next


The <legend> tag is used to assign a caption to a set of form controls defined by the <fieldset> element.

The following table summarizes the usages context and the version history of this tag.

Parent: <fieldset>
Placement: Inline
Content: Inline and text
Start/End Tag: Start tag: required, End tag: required
Version: HTML 2, 3.2, 4, 4.01, 5


The basic syntax of the <legend> tag is given with:

HTML / XHTML: <legend> ... </legend>

The example below shows the <legend> tag in action.

<form action="" method="post">
        <input type="radio" name="gender" value="male" id="male">
        <label for="male">Male</label>
        <input type="radio" name="gender" value="female" id="female">
        <label for="female">Female</label>

Tag-Specific Attributes

The following table shows the attributes that are specific to the <legend> tag.

Attribute Value Description
align top
Obsolete Specifies the alignment or position of the caption text with respect to the fieldset.

Global Attributes

Like all other HTML tags, the <legend> tag supports the global attributes in HTML5.

Event Attributes

The <legend> tag also supports the event attributes in HTML5.

Browser Compatibility

The <legend> tag is supported in all major modern browsers.

Browsers Icon

Basic Support—

  • Firefox 1+
  • Google Chrome 1+
  • Internet Explorer 4+
  • Apple Safari 1+
  • Opera 4+

Further Reading

See tutorial on: HTML Forms.

Other form-related tags: <form>, <fieldset>, <label>, <input>, <textarea>, <select>, <optgroup>, <option>, <button>.

Bootstrap UI Design Templates