HTML form
➔ HTML <form> represents a section for user input.
➔ HTML <form> contains interactive input control elements.
➔ <form> submits user information to the server for processing.
➔ User input can be variety of types like text, check box, radio selection, combo box, date, file etc.
Learning with HTML Editor "Try it Now"
You can edit the HTML code and view the result using online editor.
Example
<!DOCTYPE html>
<html>
<head>
<title>HTML Form Tag Example</title>
<meta charset="utf-8" />
<style>
input {
margin: 10px;
padding: 5px;
}
</style>
</head>
<body>
<h2>HTML Form Tag Example</h2>
<form id="myform" action="" method="get">
<div>
<label for="name">Enter your name: </label>
<input type="text" name="name" id="name" required>
</div>
<div>
<label for="email">Enter your email: </label>
<input type="email" name="email" id="email" required>
</div>
<div>
<input type="submit" value="Submit" onclick=submitForm()>
</div>
</form>
<script>
function submitForm() {
if (myform.checkValidity()) {
event.preventDefault();
alert("Form data submitted.");
}
}
</script>
</body>
</html>
Click on the "See output" button to see how it works.