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>
        <title>Wikitechy method attribute</title>
         <form action="method.html" method="get">
         <input type="text" name="txtname">  <br>
         <input type="submit" value="submit">

Code Explanation for method Attribute in HTML:

 method Attribute Code Explanation

  1. <form> tag is used to design a form for user input.
  2. method attribute is used to send the form data to the URL using get method.

Output for method Attribute in HTML:

 method Attribute Tag Output

  1. Enter the text wikitechy in the text area.
  2. Click the submit button.
  3. 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

Related Searches to method Attribute in html