Lesson 8: HTML Forms and Inputs

In this lesson, you'll learn how to create basic HTML forms and inputs to collect user information.

1. The Basic Structure of a Form

A form in HTML starts with the <form> tag and ends with the </form> tag. Inside the form, you can place various input elements like text fields, checkboxes, radio buttons, and submit buttons.

<form action="/submit_form" 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>

2. Creating Text Inputs

Text inputs allow users to enter text. You can create a text input using the <input type="text"> element. Each input field should be paired with a label to describe its purpose.

<label for="username">Username:</label>
<input type="text" id="username" name="username">

3. The Submit Button

The submit button is used to send form data to the server. It can be created using the <input type="submit"> or <button type="submit"> element.

<input type="submit" value="Submit">
Proceed to Lesson 9