Check out example codes for "html form attributes". It will help you in understanding the concepts better.
Code Example 1
The <form> tag is used to create an HTML form for user input.
The <form> element can contain one or more of the following form elements:
<input>
<textarea>
<button>
<select>
<option>
<optgroup>
<fieldset>
<label>
<output>
form tag main attributes
1. action : contains url of the page where form data get redirected on submit button click
2. method : contains method in which way it tranfer the data i.e get,post
a. get : this method shows the form data along the url in browser address bar
b. post : this method does not show any form data in url it transfer data in hidden form
---------------------------------------------------------------------------------------------
Example below :
//An HTML form with two input fields and one submit button:
<form action="/action_page.php" method="get">
<label for="fname">First name:</label>
<input type="text" id="fname" name="fname"><br><br>
<label for="lname">Last name:</label>
<input type="text" id="lname" name="lname"><br><br>
<input type="submit" value="Submit">
</form>
Code Example 2
<form action="/action.php">
<label for="fname">First name:</label><br>
<input type="text" id="fname" value="Mike"><br><br>
<label for="lname">Last name:</label><br>
<input type="text" id="lname" value="Walker"><br><br>
<input type="submit" value="Submit">
</form>
Code Example 3
<!-- Simple form which will send a POST request -->
<form action="" method="post">
<label for="POST-name">Name:</label>
<input id="POST-name" type="text" name="name">
<input type="submit" value="Save">
</form>
<!-- Form that sends a GET request -->
<!-- In this case, the information will appear in the url address bar,
corresponding to each attribute "name", of the "input" tag (don't use this
in case of input password!) -->
<form action="" method="get">
<label for="GET-name">Name:</label>
<input id="GET-name" type="text" name="name">
<input type="submit" value="Save">
</form>
<!-- Form with fieldset, legend, and label -->
<form action="" method="post">
<fieldset>
<legend>Title</legend>
<input type="radio" name="radio" id="radio"> <label for="radio">Click me</label>
</fieldset>
</form>
<!-- How to submit directly to email? -->
<form action="mailto:[email protected]" method="post" enctype="text/plain">
<label for="get_email">Your email: </label>
<input id="get_email" type="email" name="email" value="" /><br /><br />
<label for="subject">Subject Matter: </label>
<input id="subject" type="text" name="subject" value="" /><br /><br />
<label for="body_msg">Your Message: </label> <br />
<textarea name="body_msg" cols="30" rows="10">
Code Example 4
<form action="/action_page.php">
<label for="fname">First name:</label><br>
<input type="text" id="fname" name="fname" value="John"><br>
<label for="lname">Last name:</label><br>
<input type="text" id="lname" name="lname" value="Doe"><br><br>
<input type="submit" value="Submit">
</form>
The <form> tag is used to create an HTML form for user input.
The <form> element can contain one or more of the following form elements:
<input>
<textarea>
<button>
<select>
<option>
<optgroup>
<fieldset>
<label>
<output>
form tag main attributes
1. action : contains url of the page where form data get redirected on submit button click
2. method : contains method in which way it tranfer the data i.e get,post
a. get : this method shows the form data along the url in browser address bar
b. post : this method does not show any form data in url it transfer data in hidden form
---------------------------------------------------------------------------------------------
Example below :
//An HTML form with two input fields and one submit button:
<form action="/action_page.php" method="get">
<label for="fname">First name:</label>
<input type="text" id="fname" name="fname"><br><br>
<label for="lname">Last name:</label>
<input type="text" id="lname" name="lname"><br><br>
<input type="submit" value="Submit">
</form>
Code Example 5
<form>
<label for="fname">First name:</label><br>
<input
type="text" id="fname" name="fname"><br>
<label for="lname">Last
name:</label><br>
<input type="text" id="lname" name="lname">
</form>
Learn ReactJs, React Native from akashmittal.com