HTML Forms
HTML forms, defined using the <form> Tags are essential for collecting user input on web pages. They incorporate a variety of interactive controls such as text fields, numeric inputs, email fields, password fields, checkboxes, radio buttons, and submit buttons. Over 85% of websites rely on forms to gather data from users, making them a fundamental component of modern web development.
Basic HTML Forms Example
<!DOCTYPE html>
<html lang=”en”>
<head>
<meta charset=”UTF-8″> <meta name=”viewport” content=”width=device-width, initial-scale=1.0″>
<title>HTML</title>
</head>
<body>
<h2>HTML Forms</h2>
<form>
<label for=”username”>Username:</label><br>
<input type=”text” id=”username” name=”username”><br><br>
<label for=”password”>Password:</label><br>
<input type=”password” id=”password” name=”password”><br><br>
<input type=”submit” value=”Submit”>
</form>
</body>
Code Overview:
- HTML Structure:The code has a basic HTML structure with a title “HTML Forms.”
- Heading: The <h2> tag displays “HTML Forms” as the main heading on the page.
- Form Tag: The <form> tag defines a form for user input.
- Username Field: A text input field for the username with a label.
- Password Field & Submit: A password input field and a submit button to send the form data.