Subscribe Us

HTML FORMS

HTML Forms: Collecting User Input

HTML Forms: Collecting User Input

What is an HTML Form?

An HTML form is used to collect user input. It consists of various form elements like text fields, radio buttons, checkboxes, and submit buttons. Forms are enclosed within the <form> tag.

Form Elements

Here are some common form elements:

  • <input>: Creates various types of input fields. The type attribute determines the type of input (e.g., text, password, email).
  • <textarea>: Creates a multi-line text area for longer input.
  • <select>: Creates a dropdown list of options.
  • <button>: Creates a clickable button.

Example: HTML Form

Here’s an example of a simple HTML form:

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>HTML Form Example</title>
</head>
<body>
<form action="/submit" method="post">
<label for="name">Name:</label>
<input type="text" id="name" name="name">
<br>
<label for="email">Email:</label>
<input type="email" id="email" name="email">
<br>
<label>Gender:</label>
<input type="radio" id="male" name="gender" value="male">
<label for="male">Male</label>
<input type="radio" id="female" name="gender" value="female">
<label for="female">Female</label>
<br>
<input type="submit" value="Submit">
</form>
</body>
</html>

© 2024 HTML Tutorial

No comments