Example

Form Input Legend & fieldset in HTML

HTML

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Form Input Legend & fieldset in HTML</title>
</head>
<body>
<!--
    <fieldset> : is used to group related data in a form.
    <legend> : defines a caption for the <fieldset> element.
-->

    <h1>Demo: Form Input legend & fieldset in HTML</h1>

    <form action="/notes/examples/html/output/thankYou.html" target="_blank">
        
        <fieldset>
            <legend>Personal Details:</legend>
            <label for="fname">Firstname:</label><br>
            <input type="text" id="fname" name="fname" placeholder="Enter Firstname"><br>
            <label for="lname">Lastname:</label><br>
            <input type="text" id="lname" name="lname" placeholder="Enter Lastname"><br>
            <label for="lname">Email:</label><br>
            <input type="email" id="email" name="email" placeholder="Enter Email"><br><br>
        </fieldset>

        <fieldset>
            <legend>Educational Details:</legend>
            <label for="fname">10<sup>th</sup> Percentage:</label><br>
            <input type="text" id="fname" name="fname" placeholder="Enter Percentage"><br>
            <label for="lname">12<sup>th</sup> Percentage:</label><br>
            <input type="text" id="lname" name="lname" placeholder="Enter Percentage"><br>
            <label for="lname">Graduation ( CGPA ):</label><br>
            <input type="email" id="email" name="email" placeholder="Enter CGPA"><br><br>
        </fieldset><br>

        <input type="submit" value="Submit">

    </form>

</body>
</html>
                    
                    

Output

View original