Show List

HTML forms

HTML forms are used to collect user input on a web page. They allow users to enter data, such as text, numbers, and drop-down lists, and submit it to a server for processing.

The basic structure of an HTML form consists of the following elements:

  • <form>: The main container for the form.
  • <input>: Defines an input field where the user can enter data. There are various types of inputs, such as text fields, checkboxes, radio buttons, and so on.
  • <label>: Defines a label for an input element.
  • <select>: Defines a drop-down list of options.
  • <option>: Defines an individual option within a <select> element.
  • <textarea>: Defines a multi-line text input field.
  • <button>: Defines a submit button that the user can click to submit the form data to the server.

Here is an example of a simple HTML form:

<form>
  <label for="name">Name:</label>
  <input type="text" id="name" name="name">
  
  <label for="email">Email:</label>
  <input type="email" id="email" name="email">
  
  <label for="gender">Gender:</label>
  <select id="gender" name="gender">
    <option value="male">Male</option>
    <option value="female">Female</option>
    <option value="other">Other</option>
  </select>
  
  <button type="submit">Submit</button>
</form>
This form would be displayed as:



Next: Formatting


    Leave a Comment


  • captcha text