Skip to content
Related Articles

Related Articles

Improve Article
Save Article
Like Article

What is a Fieldset in HTML ?

  • Last Updated : 21 Sep, 2021

The <fieldset> is used for grouping all the controls of the form together to give it a structured look. It adds a border around the form to give it a differentiated look from all the other parts of the web page. We can also use the <legend> tag to give a caption to the form which is included inside the <fieldset>.

Syntax : 

Attention reader! Don’t stop learning now. Get hold of all the important HTML concepts with the Web Design for Beginners | HTML  course.

<fieldset>....</fieldset>

Attributes:

  • disabled: It specifies that the group of related form elements should be disabled.
  • form: It specifies that one or more forms the fieldset belongs to.
  • name: It specifies the name for the fieldset.

Example 1:



HTML




<!DOCTYPE html>
<html>
  
<body>
    <form>
        <fieldset>
            <legend>Details</legend
            Student Name: <input type="text">
            <br /> MCA Subjects: <input type="text">
            <br /> Class: <input type="text">
        </fieldset>
    </form>
</body>
  
</html>

 

Output:

Example 2:

HTML




<!DOCTYPE html>
<html>
  
<body>
    <form>
        <fieldset>
            <legend>Details</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>
            <input type="submit" value="Submit">
        </fieldset>
    </form>
</body>
  
</html>

Output:




My Personal Notes arrow_drop_up
Recommended Articles
Page :