HTML Adding a form

To add a form in HTML, you can use the <form> tag. Here's an example code for a simple form with three input fields and a submit button:

<form>
  <label for="name">Name:</label>
  <input type="text" id="name" name="name"><br>

  <label for="email">Email:</label>
  <input type="email" id="email" name="email"><br>

  <label for="message">Message:</label>
  <textarea id="message" name="message"></textarea><br>

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

In this example, <form> is the form tag. Inside the form tag, there are three input fields: a text input for the user's name, an email input for the user's email address, and a textarea input for the user's message. Each input field has a label tag associated with it, which provides a description of the input field.

 

The <input> tag has a type attribute that specifies the type of input field, such as "text", "email", "password", "checkbox", "radio", and others. The id attribute is used to uniquely identify the input field, and the name attribute is used to specify the name of the input field, which is used when the form is submitted.

 

The <textarea> tag is used for multi-line text input fields. The id and name attributes work the same way as for the <input> tag.

 

Finally, the <input> tag with type="submit" creates a submit button for the form. When the user clicks the submit button, the form data is sent to a server-side script for processing.

 

You can also add additional attributes to the form tag, such as action and method, to specify the URL of the server-side script and the HTTP method to use for submitting the form data. For example:

<form action="process-form.php" method="post">
  ...
</form>

This example sets the action attribute to "process-form.php", which is the URL of the server-side script that will process the form data when the form is submitted. The method attribute is set to "post", which means that the form data will be sent to the server as part of the HTTP request body.

Comments

There are no comments, make the firs comment