Class – 12 | HTML Forms | HTML Tutorial

HTML Forms - Class - 12
HTML Forms – Class – 12

HTML forms are an essential part of any website or web application. They allow users to interact with a website by submitting data, such as filling out a contact form, purchasing, or posting a comment.

Here’s a simple example of an HTML form:

<form>
  <label for="name">Name:</label>
  <input type="text" id="name" name="name"><br><br>
  <label for="email">Email:</label>
  <input type="email" id="email" name="email"><br><br>
  <label for="password">Password:</label>
  <input type="password" id="password" name="password"><br><br>
  <input type="submit" value="Submit">
</form>

Let’s break down this code:

  1. The <form> element is the container for the form and all its elements.
  2. The <label> element is used to give a text description for each form control. The for attribute is used to associate the label with a specific form control using its id.
  3. The <input> element is the most common form of control and is used to receive data from the user. The type attribute specifies the type of form control, such as text, email, password, checkbox, radio button, etc. The id and name attributes are used to give the form control a unique identifier.
  4. The <input type="submit"> element is used to submit the form data to a server for processing. The value attribute specifies the text that will be displayed on the button.

Note: In this example, the form data will be sent to the same page for processing, but in a real-world scenario, you would send the data to a server-side script (e.g., PHP, Python, Ruby, etc.) for processing.

This is just a basic example of an HTML form, and many more form elements and attributes are available for you to use. If you want to learn more about HTML forms, I recommend checking out the official W3Schools HTML Forms tutorial: (https://www.w3schools.com/html/html_forms.asp)

Next Class

See also  Class 42 | CSS Best Practices and Debugging Techniques

Hamza Raja

Website Developer, Blogger, Digital Marketer & Search Engine Optimization SEO Expert.

Leave a Comment