Forms in HTML

Python SELF EN
Level 29 , Lesson 3
Available

1. Introduction to Forms

Forms in HTML are an essential tool for user interaction with web pages. They allow collecting information from users, whether it's text, selecting options from a list, uploading files, or other data, which can then be sent to the server for processing. In HTML, forms are created using a bunch of elements, each designed for a specific type of input. The main form element is <form>, which includes other elements like <input>, <textarea>, <button>, <select>, and more.

Basic Form Elements

Form elements allow you to create input fields, buttons, dropdown lists, and other interface components through which users can provide data. Here are the main tags used in forms:

  • <form> — the main container for all form elements. It defines where and how the data is sent.
  • <input> — a universal element for creating input fields of various types (text, password, radio buttons, checkboxes, etc.).
  • <label> — an element associated with an input field, used to describe its purpose.
  • <textarea> — a field for entering multi-line text.
  • <button> — a button for submitting the form or performing other actions.
  • <select> and <option> — a dropdown list where users can select one or more options.

Example of a Simple Form

HTML
      
    <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">
      
      <button type="submit">Submit</button>
    </form>
    
HTML
          
<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">
  
  <button type="submit">Submit</button>
</form>
1
Task
Python SELF EN, level 29, lesson 3
Locked
Creating a Simple Form
Creating a Simple Form
2
Task
Python SELF EN, level 29, lesson 3
Locked
Form Extension
Form Extension
3
Task
Python SELF EN, level 29, lesson 3
Locked
Creating a form with a dropdown list and a textarea
Creating a form with a dropdown list and a textarea
4
Task
Python SELF EN, level 29, lesson 3
Locked
Fully Functional Registration Form
Fully Functional Registration Form
Comments
TO VIEW ALL COMMENTS OR TO MAKE A COMMENT,
GO TO FULL VERSION