html tutorial - method Attribute in HTML - html5 - html code - html form
- The method attribute defines how to send the form-data.
- The form-data is sent to the target page that can be defined in the action attribute.
- The form-data will be sent as HTTP post transaction (with method="post") or as URL variables (with method="get").
Syntax for method attribute in HTML:
<form method=”get”>
Applies To:
Elements | Attribute |
---|---|
<form> | method |
Sample Coding for method Attribute in HTML:
<!DOCTYPE html>
<html>
<head>
<title>Wikitechy method attribute</title>
</head>
<body>
<form action="method.html" method="get">
<input type="text" name="txtname"> <br>
<input type="submit" value="submit">
</form>
</body>
</html>
Code Explanation for method Attribute in HTML:

- <form> tag is used to design a form for user input.
- method attribute is used to send the form data to the URL using get method.
Output for method Attribute in HTML:

- Enter the text wikitechy in the text area.
- Click the submit button.
- After clicking the submit button, it will redirect to the same page and the name(txtname=wikitechy) has been displayed in the address bar.
Browser Support for method Attribute in HTML:
![]() |
![]() |
![]() |
![]() |
![]() |
---|---|---|---|---|
yes | yes | yes | Yes | Yes |