What is the HTML method attribute?
Overview
The method attribute in
getpost
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. Thegetmethod 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
Getand this form has the name and the email and at the end, it has the submit button.