A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://www.geeksforgeeks.org/html/html-fieldset-form-attribute/ below:

HTML <fieldset> form Attribute - GeeksforGeeks

HTML <fieldset> form Attribute

Last Updated : 11 Jul, 2025

The form attribute in the <fieldset> tag specifies which <form> element the <fieldset> belongs to.

However, when the <fieldset> is not inside the <form> (i.e., outside of the <form> element), the form attribute is used to explicitly link the <fieldset> to a specific form.

Syntax
<fieldset form="form_id">
Attribute Values: Value Description form_id The form attribute contains the form_id, which specifies the form that the <fieldset> element belongs to. The value should be the id of a <form> element. Example: html
<!DOCTYPE html>
<html>

<head>
    <title>
        HTML fieldset form Attribute
    </title>
    <style>
        h1,
        h2,
        .title {
            text-align: center;
        }
        
        fieldset {
            width: 50%;
            margin-left: 22%;
        }
        
        h1 {
            color: green;
        }
    </style>
</head>

<body>
    <h1>GeeksforGeeks</h1>
    <h2>
      HTML &lt;fieldset&gt; 
      form Attribute
  </h2>
    <form id="mygeeks">
        <div class="title">
            Suggest article for video:
        </div>
    </form>
  
    <fieldset form="mygeeks">
        <legend>JAVA:</legend>
        Title:
        <input type="text">
        <br> Link:
        <input type="text">
        <br> User ID:
        <input type="text">
    </fieldset>
    <br>
    <fieldset form="mygeeks">
        <legend>PHP:</legend>
        Title:
        <input type="text">
        <br> Link:
        <input type="text">
        <br> User ID:
        <input type="text">
    </fieldset>

</body>

</html>

Output:

In this example:

Purpose of the form Attribute:

The form attribute of the <fieldset> tag links the fieldset to a form elsewhere in the HTML document. This is particularly useful in complex web pages where the form elements are not physically contained within the <form> tag due to styling or layout requirements. By using the form attribute, developers can maintain a logical association between the <fieldset> and its corresponding <form> without altering the structure of the HTML document.

Supported Browsers

The browser supported by HTML <fieldset> form Attribute are listed below: 

Key Points

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4