Skip to content
Related Articles
Open in App
Not now

Related Articles

How to define a caption for a fieldset element in HTML5 ?

Improve Article
Save Article
  • Last Updated : 02 Jun, 2020
Improve Article
Save Article

In this article, we define a caption for a fieldset element by using the legend element. It is used to define the title for the child contents. The legend elements are the parent element.


<legend> Content... </legend>


<!DOCTYPE html>
    <title>Legend Tag</title>
        form {
            width: 50%;
        label {
            display: inline-block;
            float: left;
            clear: left;
            width: 90px;
            margin: 5px;
            text-align: left;
        input[type="text"] {
            width: 250px;
            margin: 5px 0px;
        .gfg {
            font-size: 40px;
            color: green;
            font-weight: bold;
    <div class="gfg">
    <h2>Legend tag</h2>
            <input type="text">
            <input type="text">
            <label>Date of birth:</label>
            <input type="text">
            <input type="text">
            <label>Enroll No:</label>
            <input type="text">

legend tag

Supported Browsers:

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

My Personal Notes arrow_drop_up
Related Articles

Start Your Coding Journey Now!