Skip to content

WebDevHubs

  • Home
  • JavaScript
  • Toggle search form

HTML Login Form

Posted on February 11, 2025March 15, 2025 By Admin No Comments on HTML Login Form

HTML login form is an important component of any website or web application to authenticate users. It contains input fields and submit buttons.

Login Form

Key components of a login form include:

  • Input Fields: To accept user credentials (e.g., username and password).
  • Submit Button: To send the entered information for authentication.
  • Additional Features: Options like “Remember Me, “Forgot Password” or social login options.

The login form can be created using HTML and CSS. HTML is used to create a basic structure of a form, and CSS styles are applied to the HTML element to make the form UI better.

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
<!DOCTYPE html>
<html lang="en">
<head>
<title>HTML Login Form</title>
<style>
body {
font-family: 'Arial', sans-serif;
display: flex;
align-items: center;
justify-content: center;
height: 100vh;
margin: 0;
background-color: #f5f5f5;
}
.container {
background-color: #fff;
border: 1px solid #ccc;
padding: 20px;
border-radius: 8px;
box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
width: 300px;
text-align: center;
position: relative;
}
.container label {
display: block;
text-align: left;
margin-bottom: 8px;
font-weight: bold ;
}
.container input {
width: 100%;
padding: 10px;
margin: 8px 0;
box-sizing: border-box;
border: 1px solid #ccc;
border-radius: 4px;
}
button, .container button {
background-color: #2b80ff;
color: white;
padding: 10px 15px;
border: none;
border-radius: 4px;
cursor: pointer;
}
.container button:hover {
background-color: #0066ff;
}
</style>
</head>
<body>
<div class="container">
<h2>Login Form</h2>
<form id="loginForm">
<label for="username">Username:</label>
<input type="text" id="username"
placeholder="Enter your username" required>
<label for="password">Password:</label>
<input type="password" id="password"
placeholder="Enter your password" required>
<button type="submit">Login</button>
</form>
</div>
</body>
</html>
<!DOCTYPE html> <html lang="en"> <head> <title>HTML Login Form</title> <style> body { font-family: 'Arial', sans-serif; display: flex; align-items: center; justify-content: center; height: 100vh; margin: 0; background-color: #f5f5f5; } .container { background-color: #fff; border: 1px solid #ccc; padding: 20px; border-radius: 8px; box-shadow: 0 0 10px rgba(0, 0, 0, 0.1); width: 300px; text-align: center; position: relative; } .container label { display: block; text-align: left; margin-bottom: 8px; font-weight: bold ; } .container input { width: 100%; padding: 10px; margin: 8px 0; box-sizing: border-box; border: 1px solid #ccc; border-radius: 4px; } button, .container button { background-color: #2b80ff; color: white; padding: 10px 15px; border: none; border-radius: 4px; cursor: pointer; } .container button:hover { background-color: #0066ff; } </style> </head> <body> <div class="container"> <h2>Login Form</h2> <form id="loginForm"> <label for="username">Username:</label> <input type="text" id="username" placeholder="Enter your username" required> <label for="password">Password:</label> <input type="password" id="password" placeholder="Enter your password" required> <button type="submit">Login</button> </form> </div> </body> </html>
<!DOCTYPE html>
<html lang="en">

<head>
    <title>HTML Login Form</title>

    <style>
        body {
            font-family: 'Arial', sans-serif;
            display: flex;
            align-items: center;
            justify-content: center;
            height: 100vh;
            margin: 0;
            background-color: #f5f5f5;
        }

        .container {
            background-color: #fff;
            border: 1px solid #ccc;
            padding: 20px;
            border-radius: 8px;
            box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
            width: 300px;
            text-align: center;
            position: relative;
        }

        .container label {
            display: block;
            text-align: left;
            margin-bottom: 8px;
            font-weight: bold   ;
        }

        .container input {
            width: 100%;
            padding: 10px;
            margin: 8px 0;
            box-sizing: border-box;
            border: 1px solid #ccc;
            border-radius: 4px;
        }

        button, .container button {
            background-color: #2b80ff;
            color: white;
            padding: 10px 15px;
            border: none;
            border-radius: 4px;
            cursor: pointer;
        }

        .container button:hover {
            background-color: #0066ff;
        }
    </style>
</head>

<body>
    <div class="container">
        <h2>Login Form</h2>
        <form id="loginForm">
            <label for="username">Username:</label>
            <input type="text" id="username" 
                placeholder="Enter your username" required>

            <label for="password">Password:</label>
            <input type="password" id="password" 
                placeholder="Enter your password" required>

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

</html>

Output

Login Form
CSS, HTML, Web Technologies Tags:Web-Templates

Post navigation

Previous Post: HTML Elements
Next Post: Top 10 CSS Hacks That Every Developer Should Know In 2025

More Related Articles

How to Get First and Last Elements of an Array in JavaScript? JavaScript
Get All Unique Values in a JavaScript Array (Remove Duplicates) JavaScript
Design a Simple HTML Page | First HTML Project CSS
JavaScript Array join() Method JavaScript
JavaScript Array find() Method JavaScript
JavaScript Math.tan() Method JavaScript

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Archives

  • May 2025
  • March 2025
  • February 2025
  • January 2025
  • December 2024

Categories

  • CSS
  • HTML
  • JavaScript
  • Lodash
  • PHP
  • Python
  • Uncategorized
  • Web Technologies
  • Web Templates

Recent Posts

  • How to Center Text in HTML?
  • Design a Simple HTML Page | First HTML Project
  • Best Way to Initialize an Empty Array in PHP
  • HTML Description Lists
  • HTML Ordered Lists

Recent Comments

No comments to show.

Copyright © 2025 WebDevHubs.

Powered by PressBook Green WordPress theme