HTML Forms

Introduction to Forms in HTML Forms are used to collect user input and send it to a server. Basic Form Structure Form Elements Input Fields Textarea Dropdown Select Checkboxes & Radio Buttons Form Attributes action & method autocomplete Advanced Form Elements File Upload Form Buttons HTML forms help collect user input effectively. Next, we’ll discuss […]

  • Post author:
  • Post category: HTML
  • Reading time: 51 mins read
  • Post last modified: April 3, 2025

Introduction to Forms in HTML

Forms are used to collect user input and send it to a server.

Basic Form Structure

<form action="submit.php" method="post">
    <label for="name">Name:</label>
    <input type="text" id="name" name="name" required>
    <input type="submit" value="Submit">
</form>
HTML

Form Elements

Input Fields

<input type="text" placeholder="Enter text">
<input type="email" placeholder="Enter email">
<input type="password" placeholder="Enter password">
HTML

Textarea

<textarea rows="4" cols="50">Type here...</textarea>
HTML

Dropdown Select

<select>
    <option value="option1">Option 1</option>
    <option value="option2">Option 2</option>
</select>
HTML

Checkboxes & Radio Buttons

<input type="checkbox" id="agree" name="agree">
<label for="agree">I agree</label>

<input type="radio" name="gender" value="male"> Male
<input type="radio" name="gender" value="female"> Female
HTML

Form Attributes

action & method

  • action: Specifies the URL where form data is sent.
  • method: Can be GET or POST.
<form action="process.php" method="post">
HTML

autocomplete

<input type="text" name="username" autocomplete="on">
HTML

Advanced Form Elements

File Upload

<input type="file">
HTML

Form Buttons

<button type="submit">Submit</button>
<button type="reset">Reset</button>
HTML

HTML forms help collect user input effectively. Next, we’ll discuss multimedia integration.

Leave a Reply