Cover Image for How to Create a Form in Html
72 views

How to Create a Form in Html

To create a form in HTML, you can use the <form> tag along with various form elements such as <input>, <textarea>, <select>, and more. Here’s an example of how to create a basic form:

HTML
<!DOCTYPE html>
<html>
  <head>
    <title>Form Example</title>
  </head>
  <body>
    <h1>Registration Form</h1>
    <form>
      <label for="name">Name:</label>
      <input type="text" id="name" name="name" placeholder="Enter your name" required>

      <label for="email">Email:</label>
      <input type="email" id="email" name="email" placeholder="Enter your email" required>
  
      <label for="password">Password:</label>
      <input type="password" id="password" name="password" placeholder="Enter your password" required>
  
      <label for="message">Message:</label>
      <textarea id="message" name="message" placeholder="Enter your message" required></textarea>
  
      <input type="submit" value="Submit">
    </form>
  </body>
</html>

In the above example, the <form> tag creates the form container, and each form element is enclosed within it. The label tags provide descriptive labels for each form field, and the input tags define input fields such as text, email, and password. The <textarea> tag is used for multi-line text input. The required attribute ensures that the fields are filled before submitting the form.

You can further customize the form by adding more form elements, adjusting the styling using CSS, and handling the form submission using JavaScript or server-side processing.

Remember to adjust the form elements and attributes based on your specific requirements.

YOU MAY ALSO LIKE...

The Tech Thunder

The Tech Thunder

The Tech Thunder


COMMENTS