HTML forms


HTML forms are used to store data given as input by visiters or to send them over desired place.
Content between <form> and </form> tags are known as form content.

Text input using HTML forms

<!DOCTYPE html>
<html>
<head>
<title>
HTML FORMS
</title>
</head>
<body>
<form>
Enter your name:
<input type="text" name="name"><br>
Enter your age:
<input type="number" name="age"><br>
</form>
</body>
</html>

Output:

Enter your name:

Enter your age:

Data input in HTML forms using radio buttons

<!DOCTYPE html>
<html>
<head>
<title>
HTML FORMS
</title>
</head>
<body>
<form>
<input type="radio" name="city" value="New Delhi" checked>New Delhi
<input type="radio" name="city" value="Ahmedabad" checked>Ahmedabad
<input type="radio" name="city" value="Allahabad" checked>Allahabad
<input type="radio" name="city" value="Varanasi" checked>Varanasi
</form>
</body>
</html>

Output:

New Delhi
Ahmedabad
Allahabad
Varanasi

Submitting HTML forms

We submit HTML forms by using submit button.
<!DOCTYPE html>
<html>
<head>
<title>
HTML FORMS
</title>
</head>
<body>
<form action="post.php">
Enter your name:
<input type="text" name="name"><br>
Enter your age:
<input type="number" name="age"><br>

<input type="submit" value="submit">
</form>
</body>
</html>
Here after clicking submit button form data is stored in post.php file.

Output:

Enter your name:

Enter your age: