
HTML Form
HTML Form is a container that allows users to input data into a web page and send that data to a server for processing. It is one of the most commonly used interactive elements in web development, allowing users to enter text, make selections, and interact with the website in various ways.
HTML forms are defined using the <form>
and </form>
tags. The form element can contain various form controls such as text inputs, radio buttons, checkboxes, select lists, and buttons. Each form control is defined using its own HTML tag such as <input>
, <select>
, or <textarea>
.
For example, the following HTML code creates a simple form with two text inputs and a submit button:
<form action="/submit-form" method="post">
<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>
When this code is rendered in a web browser, it will display as a form with two input fields for Name and Email, and a Submit button. When the user submits the form, the data entered into the form is sent to the server specified in the form’s action
attribute using the HTTP method specified in the method
attribute (usually POST or GET).
On the server-side, the data submitted from the form can be processed using various programming languages such as PHP, Python, or JavaScript.