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 <input> form Attribute
Next article icon

What is formmethod Attribute in HTML Form ?

Last Updated : 25 Jul, 2024
Comments
Improve
Suggest changes
Like Article
Like
Report

What is formmethod Attribute?

The form method attribute in HTML is used to define a HTTP technique that specifies how to send form-data to the backend server.  This attribute is apply on <button> , <input type= "submit"> and <input type="image">. It overrides the feature of the method attribute of the <form> element. 

How to send data?

The data can be sent to the server by using the URL variables using the GET method and as an HTTP post by using the POST method. 

What is the GET and POST Method?

  • GET Method: In the GET method, after the submission of the form, the form values will be visible in the address bar of the new browser tab. It has a limited size of about 3000 characters. It is only useful for non-secure data but not for sensitive information. It supports Bookmarking the result. It can't be used to send binary data.
  • POST Method: In the post method, after the submission of the form, the form values will not be visible in the address bar of the new browser tab as it was visible in the GET method. It appends form data inside the body of the HTTP request. It has no size limitation. This method does not support bookmarking of the result.

Example: In this example, we will use form method attribute.

HTML
<!DOCTYPE html> <html>  <head>     <title>         What is formmethod Attribute in HTML?     </title>     <style>         h3 h2 {             font-family: impact;         }     </style> </head>  <body style="text-align: center;">     <h1 style="color: green;">         GeeksforGeeks     </h1>     <h3>What is formmethod Attribute in HTML?</h3>     <form action="#" id="users" action="#"            method="GET" target="_blank">         User_id:         <input type="email" name="email"                 placeholder="Emter Email Id" />         <br /><br />         Password:         <input type="password" name="pword"                 placeholder="Enter Password" />         <br /><br />         <input type="submit" value="Submit using GET method"                 formmethod="get" />         <input type="submit" formaction="#"                 value="submit using POST method"                 formmethod="post" />     </form> </body>  </html> 

Output:

Submit form using POST Method:

Submit form using GET Method:


Next Article
HTML <input> form Attribute

M

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

Similar Reads

  • What is formenctype Attribute in HTML Form ?
    The HTML formenctype attribute is used to specify the type of encoding to be used when submitting the form. It defines how the form data should be encoded when it is sent to the server. It works with the input type "submit" and input type "image". The formenctype attribute is used when there are mul
    2 min read
  • HTML | input formmethod Attribute
    The HTML <input> formmethod Attribute is used to specify the HTTP method for sending form-data to the action URL. This attribute is used to override the method attribute of the <form> element. Syntax: <input formmethod="get | post"> Attribute Values: get: It has a default value. In
    2 min read
  • HTML formmethod Attribute
    The HTML formmethod Attribute is used to define the HTTP method that is used to send form data while submitting the form. GET and POST are the two well-known HTTP methods. This attribute overrides the feature of the method attribute of the <form> element.  Supported tags:  <input><but
    2 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 <input> form Attribute
    The HTML <input> form Attribute is used to specify interactive input fields for web-based forms. A form can contain multiple input fields to accept inputs from the users. It is the most powerful element in HTML. Syntax: <input form="form_id"> Attribute Value: This attribute contains a si
    1 min read
  • HTML | <input> formtarget Attribute
    The HTML <input> formtarget attribute is used to specify the name or a keyword which indicates where to display the response after submitting the form. This attribute overrides the target attribute of <form> element. Syntax: <input formtarget="_blank|_self|_parent|_top|framename">
    1 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
  • How to use formaction attribute in HTML ?
    In this article, we will learn how to use the formaction attribute in HTML. Basically, the information attribute is used to define where to send the data of the form after submitting the form the working of formaction will begin. It overrides the feature of the action attribute of the <form> e
    2 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 <keygen> form Attribute
    The HTML <keygen> form attribute is used to specify one or more forms that the <keygen> element belongs to. Syntax: <keygen form="form_id"> Attribute Values: It contains single value form_id which specifies the one or more than one form that Keygen elements belong to. The value of
    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