Open In App

How To Create Registeration Form in HTML

Last Updated : 16 Oct, 2024
Comments
Improve
Suggest changes
Like Article
Like
Report

HTML Registration Form is a web-based form designed to collect user information such as name, email, password, and other details. It typically includes input fields, validation, and a submit button to register users on a website.

HTML-Registration-Form
HTML Registration Form

How to Create HTML Registration Form

  • Basic Structure: A responsive registration form is created using HTML and CSS for styling, with a simple layout and input fields.
  • Form Inputs: The form includes inputs for first name, last name, email, password (with validation pattern), contact number, and gender selection.
  • Styling: CSS is used for a modern, centered form layout with a clean design, including background color, box-shadow, and input styling.
  • Password Validation: A password pattern enforces strong security, requiring at least one number, letter, symbol, and a minimum length of 8 characters.
  • Submit Button: A styled submit button is provided with a cursor: pointer for user interaction.

Example: Implementation of a Form with multiple input tags.

HTML
<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>HTML Registration Form</title>
    <style>
        body {
            font-family: Arial, sans-serif;
            margin: 0;
            padding: 0;
            display: flex;
            justify-content: center;
            align-items: center;
            height: 100vh;
        }

        .main {
            background-color: #fff;
            border-radius: 15px;
            box-shadow: 0 0 20px rgba(0, 0, 0, 0.2);
            padding: 20px;
            width: 300px;
        }

        .main h2 {
            color: #4caf50;
            margin-bottom: 20px;
        }

        label {
            display: block;
            margin-bottom: 5px;
            color: #555;
            font-weight: bold;
        }

        input[type="text"],
        input[type="email"],
        input[type="password"],
        select {
            width: 100%;
            margin-bottom: 15px;
            padding: 10px;
            box-sizing: border-box;
            border: 1px solid #ddd;
            border-radius: 5px;
        }

        button[type="submit"] {
            padding: 15px;
            border-radius: 10px;
            border: none;
            background-color: #4caf50;
            color: white;
            cursor: pointer;
            width: 100%;
            font-size: 16px;
        }
    </style>
</head>

<body>
    <div class="main">
        <h2>Registration Form</h2>
        <form action="">
            <label for="first">First Name:</label>
            <input type="text" id="first" name="first" required />

            <label for="last">Last Name:</label>
            <input type="text" id="last" name="last" required />

            <label for="email">Email:</label>
            <input type="email" id="email" name="email" required />

            <label for="password">Password:</label>
            <input type="password" id="password" name="password"
                   pattern="^(?=.*\d)(?=.*[a-zA-Z])(?=.*[^a-zA-Z0-9])\S{8,}$" 
                   title="Password must contain at least one number, 
                           one alphabet, one symbol, and be at 
                           least 8 characters long" required />

            <label for="repassword">Re-type Password:</label>
            <input type="password" id="repassword" name="repassword" required />

            <label for="mobile">Contact:</label>
            <input type="text" id="mobile" name="mobile" maxlength="10" required />

            <label for="gender">Gender:</label>
            <select id="gender" name="gender" required>
                <option value="male">
                    Male
                </option>
                <option value="female">
                    Female
                </option>
                <option value="other">
                    Other
                </option>
            </select>

            <button type="submit">
                Submit
            </button>
        </form>
    </div>
</body>

</html>

Output


Article Tags :

Similar Reads