Skip to content
geeksforgeeks
  • Courses
    • DSA to Development
    • Get IBM Certification
    • Newly Launched!
      • Master Django Framework
      • Become AWS Certified
    • For Working Professionals
      • Interview 101: DSA & System Design
      • Data Science Training Program
      • JAVA Backend Development (Live)
      • DevOps Engineering (LIVE)
      • Data Structures & Algorithms in Python
    • For Students
      • Placement Preparation Course
      • Data Science (Live)
      • Data Structure & Algorithm-Self Paced (C++/JAVA)
      • Master Competitive Programming (Live)
      • Full Stack Development with React & Node JS (Live)
    • Full Stack Development
    • Data Science Program
    • All Courses
  • Tutorials
    • Data Structures & Algorithms
    • ML & Data Science
    • Interview Corner
    • Programming Languages
    • Web Development
    • CS Subjects
    • DevOps And Linux
    • School Learning
  • Practice
    • Build your AI Agent
    • GfG 160
    • Problem of the Day
    • Practice Coding Problems
    • GfG SDE Sheet
  • Contests
    • Accenture Hackathon (Ending Soon!)
    • GfG Weekly [Rated Contest]
    • Job-A-Thon Hiring Challenge
    • All Contests and Events
  • HTML Tutorial
  • HTML Exercises
  • HTML Tags
  • HTML Attributes
  • Global Attributes
  • Event Attributes
  • HTML Interview Questions
  • HTML DOM
  • DOM Audio/Video
  • HTML 5
  • HTML Examples
  • Color Picker
  • A to Z Guide
  • HTML Formatter
Open In App
Next Article:
HTML <fieldset> name Attribute
Next article icon

HTML <fieldset> form Attribute

Last Updated : 17 Apr, 2025
Comments
Improve
Suggest changes
Like Article
Like
Report

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:

ValueDescription
form_idThe 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:

  • <form id="mygeeks">: A form element identified by id="mygeeks". It contains no form controls directly under it but serves as a logical container for the inputs defined in the subsequent fieldsets.
    • <div class="title">: A division formatted with centered text, serving as a section title within the form.
  • Two <fieldset> Elements:
    • Both fieldsets use the form="mygeeks" attribute, explicitly associating them with the form whose id is “mygeeks”. This connection allows inputs within these fieldsets to be part of the “mygeeks” form data, even though they are not nested within the <form> tag in the HTML structure.
    • First <fieldset>
      • <legend>: Defines a caption for the fieldset, “JAVA:”, indicating that the inputs within this fieldset are related to Java topics.
      • Inputs: Contains three input fields for “Title”, “Link”, and “User ID”. Each label is followed by an input field, separated by line breaks (<br>).
    • Second <fieldset>:
      • Similar to the first, with a <legend> of “PHP:”, and the same structure of inputs for “Title”, “Link”, and “User ID”.

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: 

  • Google Chrome
  • Edge 12 and above
  • Internet Explorer
  • Firefox
  • Opera
  • Safari

Key Points

  • By default, a <fieldset> is part of the nearest enclosing <form> element.
  • A <fieldset> element located outside a form (but still a part of the form).
  • It allows grouping form elements in a logical structure, making the form more organized and accessible.


Next Article
HTML <fieldset> name Attribute

M

manaschhabra2
Improve
Article Tags :
  • HTML
  • Web Technologies
  • HTML-Attributes

Similar Reads

    HTML Form Element Attributes

    • HTML <form> method Attribute
      The HTML <form> method Attribute is used to specify the HTTP method used to send data while submitting the form. There are two kinds of HTTP methods, which are GET and POST. The method attribute can be used with the <form> element.  Syntax: <form method="get | post">Attribute Value
      2 min read

    • HTML | <form> name Attribute
      The HTML <form> name Attribute is used to specify the name of a form Element. It is used to reference the form-data after submitting the form or to reference the element in a JavaScript. Syntax: <form name="name"> Attribute Values: It contains a single value name which describes the name
      1 min read

    • HTML <form> target Attribute
      In this article, we will see how to open the new tab in HTML using <form> target Attribute, along with understanding its implementation through the examples. The <form> target Attribute in HTML is used to specify whether the submitted result will open in the current window, a new tab, or
      2 min read

    • HTML < form> autocomplete Attribute
      The HTML <form> autocomplete attribute allows the browser to automatically fill the form fields based on previous user inputs. Used to save time by reusing data like names, emails, and addresses.It can be turned "on" or "off" depending on the field's requirements.Syntax<form autocomplete="o
      3 min read

    • HTML <form> accept-charset Attribute
      The HTML <form> accept-charset attribute defines which character encoding the form will use when submitting data. By default, the accept-charset attribute is set to 'UNKNOWN,' using the same encoding as the document.It ensures the correct encoding when the form is submitted, especially for non
      3 min read

    • HTML | <form> enctype Attribute
      The HTML <form> enctype Attribute is used to specify that data that will be present in form should be encoded when submitting to the server. This type of attribute can be used only if method = “POST”. Syntax: <form enctype="value"> Attribute Value: This attribute contains three value whi
      1 min read

    • HTML <form> rel Attribute
      The HTML <form> rel attribute is used to define the relationship between the current document and the linked document. The "rel" stands for relationship. It denotes that, we connect an external CSS with the HTML page. Syntax: <form rel="value"> Attribute values: external: It specifies th
      2 min read

    • HTML | <form> accept Attribute
      The <form> accept attribute in HTML is used to specifies the type of file that the server accepts. This attribute can be used with <input type="file"> element only. This attribute is not used for validation tool because file uploads should be validated on the Server. Syntax: <form acc
      1 min read

    • HTML | <form> novalidate Attribute
      The HTML <form> novalidate Attribute is used to specify that the form-data should not be validated when submitting the form. It is a Boolean attribute. Syntax: <form novalidate> Example-1: This Example illustrates the use of novalidate Attribute in the form Element. C/C++ Code &lt;!D
      1 min read

    • HTML | <form> onreset Attribute
      The HTML <form> onreset Attribute is used to specify the form reset fields. Syntax: <form onreset = "script"> Attribute Value: This attribute contains single value script which works when onreset event call. Example: <!DOCTYPE html > <html> <head> <title> HTML for
      1 min read

    HTML Input Element Attributes

    • HTML <input> align Attribute
      The HTML <input> align attribute is used with <input type=” image”> to set the horizontal alignment of the image. It is not supported by HTML 5. Note: Since <input type=” image”> is not supported by HTML5 you can use CSS there instead of this attribute. The syntax for CSS <input
      1 min read

    • HTML input maxlength Attribute
      The maxlength attribute in the HTML <input> element is used to define the maximum number of characters that can be entered into the field. If no value is specified, or if an invalid value is provided, the input field will have no maximum length. The length is determined in UTF-16 code units, w
      2 min read

    • HTML | <input> name Attribute
      The HTML <input> name Attribute is used to specify a name for an <input> element. It is used to reference the form-data after submitting the form or to reference the element in a JavaScript. Syntax: <input name="name"> Attribute Values: It contains a single value name which describ
      1 min read

    HTML Textarea Element Attributes

    • HTML <textarea> autocomplete Attribute
      The HTML <textarea> autocomplete Attribute is used to specify whether the Textarea field has autocomplete on or off. When the autocomplete attribute is set to on, the browser will automatically complete the values based on which the user entered before. It works with many input fields such as
      1 min read

    • HTML <textarea> autofocus Attribute
      The HTML <textarea> autofocus Attribute is used to specify that the textarea field should get automatically focus when the page loads. It is a Boolean Attribute. Syntax: <textarea autofocus> Example: This Example illustrates the use of autofocus attribute in Textarea Element. C/C++ Code
      1 min read

    • HTML | <textarea> cols Attribute
      The HTML <textarea> cols Attribute is used to tell the browser how many average-width characters should fit on a single line i.e the number of columns to display. It is used to specify the visible width of the <Textarea> Element. Syntax: <textarea cols="number"> Attribute Values: I
      1 min read

    HTML Button Element Attributes

    • HTML <button> disabled Attribute
      The HTML <button> disabled attribute prevents user interaction with the button, making it unclickable and visually indicating its disabled state. It's typically used to indicate that a button is inactive or unavailable for interaction. Syntax: <button disabled></button>HTML Button
      2 min read

    • HTML | <button> type Attribute
      The <button> type attribute is used to specify the type of button. It specifies the type attribute of <button> element. The default types of <button> element can vary from browser to browser. Syntax: <button type="button|submit|reset"> Attribute Values: submit: It defines a s
      1 min read

    • HTML <button> autofocus Attribute
      The HTML <button> autofocus Attribute is used to specify whether the button should get automatically get focused or not when the page loads. It is a Boolean Attribute. Syntax: <button type="button" autofocus> Example: This Example illustrates the use of autofocus attribute in Button Elem
      1 min read

    • HTML | <button> formaction Attribute
      The HTML <button> formaction Attribute is used to specify where to send the data of the form. After submission of form the formaction attribute called. The form data is to be sent to the server after submission of form. It overrides the feature of the action attribute of an <form> elemen
      1 min read

    • HTML | <button> formtarget Attribute
      The HTML Button formtarget Attribute is used to specify whether the submitted result will open in the current window, a new tab or on a new frame. This Attribute overrides the feature of the <form>Target Attribute. It can only be used with the Button type="submit" Syntax: <button type="subm
      2 min read

    • HTML | <button> form Attribute
      The HTML <button> form Attribute is used to specify the one or more forms that the <button> element belongs to. Syntax: <button form="form_id"> Attribute Values: form_id: It Contains the value i.e form_id which specify the one or more than the button element belongs to. The value o
      1 min read

    • HTML | <button> name Attribute
      The <button> name attribute is used to specify the name attribute of <button> element. It is used to reference the form-data after submitting the form or to reference the element in a JavaScript. Syntax: <button name="name"> Attribute Values: It contains a single value name which d
      1 min read

    • HTML | <button> formmethod Attribute
      The HTML button formmethod Attribute is used to specify the HTTP method used to send data while submitting the form. There are two kinds of HTTP methods, which are GET and POST. This Attribute is only used with the Button type="submit". Syntax: <button type="submit" formmethod="get|post"> Attr
      2 min read

    • HTML <button> value Attribute
      The value attribute for <button> element in HTML is used to specify the initial value of the button element. Syntax: <button value = "value"> Example: C/C++ Code &lt;!DOCTYPE html&gt; &lt;html&gt; &lt;head&gt; &lt;title&gt;HTML button value Attribute&l
      1 min read

    • HTML | <button> formenctype Attribute
      The HTML <button> formenctype Attribute is used to specify that the form data should be encoded when submitting to the server. This attribute will override the feature of the formencrypt attribute. It can only be used with the Button type= "submit". Syntax: <button type="submit" formenctype
      2 min read

    • HTML | <button> formnovalidate Attribute
      The HTML <button> formnovalidate Attribute is used to specify that the Form data should not be validated when submitting the Form. This Attribute is a Boolean Attribute. It overrides the feature of the form's novalidate Attribute. It can only be used with the <button type="submit">. Synt
      1 min read

    HTML Select Element Attributes

    • HTML <select> disabled Attribute
      The disabled attribute for <select> element in HTML is used to specify that the select element is disabled. A disabled drop-down list is un-clickable and unusable. It is a boolean attribute. Syntax: <select disabled>option values...</select> Example: C/C++ Code &lt;!DOCTYPE htm
      1 min read

    • HTML | <select> autocomplete Attribute
      The HTML <select> autocomplete attribute is used to specify that the form has autocompleted on or off. When the autocomplete attribute is set to on the browser will automatically complete the values based on which the user entered before. Syntax: <select autocomplete="on | off"> Attribut
      1 min read

    • HTML | <select> name Attribute
      The HTML <select> name Attribute is used to specify a name for the drop-down list. It is used to reference the form-data after submitting the form or to reference the element in a JavaScript. Syntax: <select name="text"> Attribute Values: It contains the value i.e name which specify the
      1 min read

    • HTML <select> form Attribute
      The form attribute in HTML <select> specifies the dropdown list's associated form, identified by the id attribute of a <form> element. Syntax: <select form="form_id">Attribute Values: Name Description value <option> value is sent on form submission, text displays in dropdown.
      1 min read

    • HTML | <select> required Attribute
      The HTML <select> required Attribute is a Boolean attribute which is used to specify that the user should be selected value before submitting the Form. syntax: <select required> Example: This Example illustrates the use of required attribute in select element. C/C++ Code &lt;!DOCTYPE
      1 min read

    • HTML | <select> size Attribute
      The HTML size Attribute is used to specifies the number of visible options in a drop-down list. Note: If the value of the size attribute is greater than 1 but lower that the number of options in a DropDown List. so the Browser will automatically add the scrollbar for specifying that there are more o
      1 min read

    • HTML | <select> multiple Attribute
      The HTML <select> multiple Attribute is a Boolean Attribute. It specifies that the user is allowed to select more than one value that presents in <select> element. Syntax: <select multiple> Example: C/C++ Code &lt;html&gt; &lt;body&gt; &lt;center&gt; &lt
      1 min read

    • HTML <select> autofocus Attribute
      The HTML <select autofocus> attribute allows a dropdown menu (select element) to receive focus when the page loads automatically. It is a boolean attribute, meaning its presence alone activates this behavior without requiring a value. Syntax<select autofocus>Example: This example shows t
      2 min read

    HTML Option Element Attributes

    • HTML | <option> selected Attribute
      The HTML <option> selected Attribute is used to specify which option should be by default selected when the page loads. This is a boolean attribute. The option that is having the selected attribute will be displayed by default.Syntax: <option selected> Example-1: This Example illustrates
      1 min read

    • HTML | <option> label Attribute
      The HTML option label Attribute is used to specify the text value which represents the shorted label for option. The shortest version will be displayed in the drop-down list. Syntax: <option label="text"> Attribute Values: It contains single value text which specify the shorter version for an
      1 min read

    • HTML <option> value Attribute
      HTML <option> value attribute determines the data sent to the server upon form submission, while the text content represents the visible options in dropdown menus. Syntax: <option value = "value">Attribute Value: It contains a single value that has to be sent to the server.  HTML option
      1 min read

    • HTML <option> disabled Attribute
      The disabled attribute for <option> element in HTML is used to specify that the option value is disabled. A disabled option is un-clickable and unusable. It is a boolean attribute. Syntax: <option disabled>option values...</option> Example: C/C++ Code &lt;!DOCTYPE html&gt;
      1 min read

    HTML Optgroup Element Attributes

    • HTML | <optgroup> label Attribute
      The HTML optgroup label Attribute is used to specify a label for an <optgroup> Element. Syntax: <optgroup label="text"> Attribute Values: It contains the value i.e text which specify the description for a optgroup Element. Example: <!DOCTYPE html> <html> <head> <titl
      1 min read

    • HTML <optgroup> disabled Attribute
      The disabled attribute for <optgroup> element in HTML is used to specify that the option-group is disabled. A disabled optgroup is un-clickable and unusable. It is a boolean attribute. Syntax: <optgroup disabled>option value...</optgroup> Example: C/C++ Code &lt;!DOCTYPE html
      1 min read

    HTML Label Element Attributes

    • HTML <label> for Attribute
      The HTML <label> for Attribute is used to specify the type of form element a label is bound to. Syntax: <label for="element_id"> Attribute Values: It contains the value i.e element_id which specify the id of the element that the label is bound to. Example: This Example that illustrates t
      1 min read

    • HTML <label> form Attribute
      The HTML <label> form Attribute is used to specify the form to which the label belongs, associating it with a specific input element. Syntax: <label form="form_id"> Attribute Values: The form attribute in HTML's <label> tag specifies the id of the <form> element to which the
      1 min read

    HTML Fieldset Element Attributes

    • HTML <fieldset> form Attribute
      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
      3 min read

    • HTML <fieldset> name Attribute
      The HTML <fieldset> name Attribute is used to specify the name for the Fieldset element. It is used to reference the form data after submitting the form or to reference the element in JavaScript. Syntax: <fieldset name="text"> Attribute Values: It contains the value i.e. name which speci
      1 min read

    • HTML | <fieldset> autocomplete attribute
      The HTML <fieldset> autocomplete attribute is used to specify that the fieldset has autocompleted on or off value. When the autocomplete attribute is set to on the browser will automatically complete the values base on which the user entered before. Syntax: <fieldset autocomplete="on | off"
      1 min read

    HTML Legend Element Attributes

    • HTML | <legend> align Attribute
      The <legend> align attribute in HTML is used to specify the alignment of the caption in a <fieldset> element. The left and right alignment of <legend> element are supported by major browsers except Opera 12 and earlier versions. The bottom alignment are not supported by any browser
      2 min read

    • HTML | <legend> form Attribute
      The HTML <legend> form Attribute is used to specify the one or more forms that the legend element belongs to. Syntax: <legend form="form_id"> Attribute Values: form_id: It Contains the value i.e form_id which specify the one or more than the button element belongs to. The value of this a
      1 min read

geeksforgeeks-footer-logo
Corporate & Communications Address:
A-143, 7th Floor, Sovereign Corporate Tower, Sector- 136, Noida, Uttar Pradesh (201305)
Registered Address:
K 061, Tower K, Gulshan Vivante Apartment, Sector 137, Noida, Gautam Buddh Nagar, Uttar Pradesh, 201305
GFG App on Play Store GFG App on App Store
Advertise with us
  • Company
  • About Us
  • Legal
  • Privacy Policy
  • In Media
  • Contact Us
  • Advertise with us
  • GFG Corporate Solution
  • Placement Training Program
  • Languages
  • Python
  • Java
  • C++
  • PHP
  • GoLang
  • SQL
  • R Language
  • Android Tutorial
  • Tutorials Archive
  • DSA
  • Data Structures
  • Algorithms
  • DSA for Beginners
  • Basic DSA Problems
  • DSA Roadmap
  • Top 100 DSA Interview Problems
  • DSA Roadmap by Sandeep Jain
  • All Cheat Sheets
  • Data Science & ML
  • Data Science With Python
  • Data Science For Beginner
  • Machine Learning
  • ML Maths
  • Data Visualisation
  • Pandas
  • NumPy
  • NLP
  • Deep Learning
  • Web Technologies
  • HTML
  • CSS
  • JavaScript
  • TypeScript
  • ReactJS
  • NextJS
  • Bootstrap
  • Web Design
  • Python Tutorial
  • Python Programming Examples
  • Python Projects
  • Python Tkinter
  • Python Web Scraping
  • OpenCV Tutorial
  • Python Interview Question
  • Django
  • Computer Science
  • Operating Systems
  • Computer Network
  • Database Management System
  • Software Engineering
  • Digital Logic Design
  • Engineering Maths
  • Software Development
  • Software Testing
  • DevOps
  • Git
  • Linux
  • AWS
  • Docker
  • Kubernetes
  • Azure
  • GCP
  • DevOps Roadmap
  • System Design
  • High Level Design
  • Low Level Design
  • UML Diagrams
  • Interview Guide
  • Design Patterns
  • OOAD
  • System Design Bootcamp
  • Interview Questions
  • Inteview Preparation
  • Competitive Programming
  • Top DS or Algo for CP
  • Company-Wise Recruitment Process
  • Company-Wise Preparation
  • Aptitude Preparation
  • Puzzles
  • School Subjects
  • Mathematics
  • Physics
  • Chemistry
  • Biology
  • Social Science
  • English Grammar
  • Commerce
  • World GK
  • GeeksforGeeks Videos
  • DSA
  • Python
  • Java
  • C++
  • Web Development
  • Data Science
  • CS Subjects
@GeeksforGeeks, Sanchhaya Education Private Limited, All rights reserved
We use cookies to ensure you have the best browsing experience on our website. By using our site, you acknowledge that you have read and understood our Cookie Policy & Privacy Policy
Lightbox
Improvement
Suggest Changes
Help us improve. Share your suggestions to enhance the article. Contribute your expertise and make a difference in the GeeksforGeeks portal.
geeksforgeeks-suggest-icon
Create Improvement
Enhance the article with your expertise. Contribute to the GeeksforGeeks community and help create better learning resources for all.
geeksforgeeks-improvement-icon
Suggest Changes
min 4 words, max Words Limit:1000

Thank You!

Your suggestions are valuable to us.

What kind of Experience do you want to share?

Interview Experiences
Admission Experiences
Career Journeys
Work Experiences
Campus Experiences
Competitive Exam Experiences