Trusted answers to developer questions
Trusted Answers to Developer Questions

Related Tags

html
css
community creator

What is the HTML method attribute?

Behzad Ahmad

Grokking Modern System Design Interview for Engineers & Managers

Ace your System Design Interview and take your career to the next level. Learn to handle the design of applications like Netflix, Quora, Facebook, Uber, and many more in a 45-min interview. Learn the RESHADED framework for architecting web-scale applications by determining requirements, constraints, and assumptions before diving into a step-by-step design process.

Overview

The method attribute in HTMLHypertext Markup Language is used to define the method used by HTTP to submit the form. There are two types of HTTP methods:

  • get
  • post

Note: The method attribute is used with the <form> element.

Syntax


<form method = "get|post">

Parameters

This method takes the following parameters:

  • get: It is the default value. The get method is not used to send sensitive data because if we use it, then after the form submission, the values in the form are displayed in the address bar of the next window. We can only send the data of 3000 characters because its size is limited.

  • Post: The Post method appends the data in the body of the HTTP request. If we use this method, then there is no size limitation. We can use this to send sensitive data.

Code

The basic HTML code to demonstrate the use of the method attribute is as follows:

Explanation

  • Line 3: We have made a heading and set it’s color to blue.

  • Line 5-11: In these lines, we have made the form whose method is set to Get and this form has the name and the email and at the end, it has the submit button.

RELATED TAGS

html
css
community creator

Grokking Modern System Design Interview for Engineers & Managers

Ace your System Design Interview and take your career to the next level. Learn to handle the design of applications like Netflix, Quora, Facebook, Uber, and many more in a 45-min interview. Learn the RESHADED framework for architecting web-scale applications by determining requirements, constraints, and assumptions before diving into a step-by-step design process.

Keep Exploring