Adding Input Fields
The <form>
element has a few attributes that can be used to control the appearance of the form. The action
attribute specifies the URL of the page that will be called when the form is submitted. The method
attribute specifies the method that will be used to submit the form. The enctype
attribute specifies the encoding that will be used to submit the form.
The <input>
element has a few attributes that can be used to control the appearance and behavior of the input field. The type
attribute specifies the type of input field. The name
attribute specifies the name of the input field. The value
attribute specifies the initial value of the input field.
Here is an example of a simple form:
<form action="">
<label for="name">Name:</label>
<input type="text" id="name" name="name">
<br>
<label for="email">Email:</label>
<input type="email" id="email" name="email">
<br>
<input type="submit" value="Submit">
</form>
Task
Add a Name, Email fields, and a submit button with appropriate attributes and values within the form given in the editor. Run the code to see the results and experiment with the code to get used to it.
Examples
Here are some examples of forms:
- A contact form.
- A registration form.
- A login form.
- A survey form.
- A shopping cart form.