Friday, July 26, 2024

HTML Forms

 

HTML forms are used to collect user input and submit it to a server for processing. The <form> tag encompasses form elements like text fields, checkboxes, radio buttons, and submit buttons. The action attribute specifies the URL where the form data will be sent, while the method attribute determines the HTTP method (GET or POST). Forms enhance interactivity by allowing users to enter and submit data.

Examples:

<form action="/submit" method="post">

  <label for="name">Name:</label>

  <input type="text" id="name" name="name">

 
  <label for="email">Email:</label>

  <input type="email" id="email" name="email">
 

  <input type="submit" value="Submit">

</form>



HTML Code:

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>HTML Tutorial</title>
</head>
<body>
    <h1>HTML Forms</h1>
    <p>HTML forms are used to collect user input. They are defined with the <code>&lt;form&gt;</code> tag.</p>
    <form action="/submit" method="post">
      <label for="name">Name:</label>
      <input type="text" id="name" name="name">
      
      <label for="email">Email:</label>
      <input type="email" id="email" name="email">
      
      <input type="submit" value="Submit">
    </form>

</body>
</html>

The Output of the above code:


HTML Tutorial

HTML Forms

HTML forms are used to collect user input. They are defined with the <form> tag.