HTML legend tag
HTML

HTML legend tag

Editorial Team
Editorial Team

Follow us on Discord or Telegram to get access to free tutorials and updates.

The HTML <legend> tag represents a caption for the <fieldset> element. This tag does not have any special attributes, only HTML global attributes are supported.

Example

<fieldset>
    <legend>Choose a language</legend>

    <input type="radio" id="cs" name="language">
    <label for="cs">C#</label><br/>
    <input type="radio" id="java" name="language">
    <label for="sasquatch">Java</label><br/>
    <input type="radio" id="php" name="language">
    <label for="mothman">PHP</label>
</fieldset>

Output

Choose a language

Attributes

The legend tag supports HTML Global attributes.

AttributeValueDescription
aligntop
bottom
left
right
Specifies the alignment of the caption. 
This attribute is not supported in HTML 5.