View video tutorial

HTML <legend> Tag

HTML

The <legend> element defines a caption or a title for the <fieldset> element.

HTML <legend> Tag


The <legend> tag represents a caption for the content of <fieldset> element.

Global attributes

Global attributes may be applied on all elements, although some elements may have no effect on them.

<accesskey>, <class>, <contenteditable>, <contextmenu>, <data-*>, <dir>, <draggable>, <dropzone>, <hidden>, <id>, <lang>, <spellcheck>, <style>, <tabindex>, <title>, <translate>.

Learning with HTML Editor "Try it Now"

You can edit the HTML code and view the result using online editor.

Example

<fieldset>
    <legend>Information:</legend>
    <label for="fname">First name:</label>
    <input type="text" id="fname" name="fname"><br><br>
    <label for="lname">Last name:</label>
    <input type="text" id="lname" name="lname"><br><br>
    <label for="email">Email:</label>
    <input type="email" id="email" name="email"><br><br>
    <label for="dob">Date of Birth:</label>
    <input type="date" id="dob" name="dob"><br><br>
    <input type="submit" value="Submit">
</fieldset>
Try it Now »

Click on the "Try it Now" button to see how it works.