HTML Exercises
Create a Registration Form
Create a simple registration form with the following fields:
Username
Email
Password
- Save and open
index.htmlin your browser to view your website.
The form should also include a "Submit" button.
HTML
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Registration Form</title>
</head>
<body>
<h2>Registration Form</h2>
<!-- Registration form begins here -->
<form action="#" method="post">
<!-- Username Field -->
<label for="username">Username:</label>
<input type="text" id="username" name="username" required><br><br>
<!-- Email Field -->
<label for="email">Email:</label>
<input type="email" id="email" name="email" required><br><br>
<!-- Password Field -->
<label for="password">Password:</label>
<input type="password" id="password" name="password" required><br><br>
<!-- Submit Button -->
<input type="submit" value="Register">
</form>
</body>
</html>
Feel free to customize the content and structure as you like.
Explanation:
- Form Tags (<form>): Wraps the form elements and uses the action attribute to define where the form data will be sent (in this case, it points to # for demo purposes).
- Input Fields:
- The type="text" field for the username.
- The type="email" field for the email, which ensures proper email formatting.
- The type="password" field hides the password as it’s typed.
- required Attribute: Ensures the user cannot submit the form without entering a value in each field.
- Submit Button: The form uses a standard submit button to send the data.
Task for the Student:
- Modify the labels and placeholders to fit your needs.
- Experiment with adding more fields like a confirm password or a "Terms and Conditions" checkbox.