How to create Form in HTML

What is HTML Form

An HTML form is used to collect user data so let’s see how we can create a form in HTML.

Here is the sample code of HTML form

<!DOCTYPE html>
<html>
<body>

<h2>HTML Forms</h2>

<form action="/your-action.php">
  <label for="fname">First name:</label><br>
  <input type="text" id="fname" name="fname" value="hack"><br>
  <label for="lname">Last name:</label><br>
  <input type="text" id="lname" name="lname" value="Tube5"><br><br>
  <input type="submit" value="Submit">
</form> 

<p>If you click the "Submit" button, the form-data will be sent to a page called "/your-action.php".</p>

</body>
</html>

Leave a Reply