How To Make A Login Page In Html And Css

How To Articles

Creating a login page is an essential part of many websites, as it allows users to access personalized content and secure their accounts. In this article, I will guide you through the process of building a login page using HTML and CSS, while adding some personal touches and commentary along the way.

Before We Begin

Before diving into the code, let’s take a moment to outline what our login page will include. We want our login page to be user-friendly and visually appealing. To achieve this, we’ll incorporate some design elements such as a clean layout, visually pleasing colors, and subtle animations. Additionally, we’ll add some personal touches to make the login experience more unique, such as a custom logo or personalized welcome message.

HTML Structure

First, let’s start by creating the basic structure of our login page. We’ll use HTML to define the elements and their hierarchy. Here’s an example of how our HTML structure may look:

<!-- HTML Structure -->
<div class="login-container">
<div class="login-header">
<img src="logo.png" alt="Logo">
<h1>Welcome back!</h1>

<form class="login-form">
<input type="text" id="username" name="username" placeholder="Username">
<input type="password" id="password" name="password" placeholder="Password">
<button type="submit">Login</button>

In the above code snippet, we wrap our login page content inside a <div> with a class of “login-container”. Inside that, we have a header section with a custom logo image and a welcome message. Below the header, we have a login form that includes input fields for the username and password, as well as a submit button.

CSS Styling

Now that we have our HTML structure in place, we can move on to applying some CSS styles to make our login page visually appealing. Here’s an example of how we can style our login page:

/* CSS Styling */
.login-container {
max-width: 400px;
margin: 0 auto;
padding: 40px;
border: 1px solid #ccc;
border-radius: 5px;
background-color: #f2f2f2;

.login-header {
text-align: center;
margin-bottom: 20px;

.login-header img {
width: 100px;
height: 100px;

.login-form input {
display: block;
width: 100%;
padding: 10px;
margin-bottom: 10px;
border: 1px solid #ccc;
border-radius: 4px;

.login-form button {
width: 100%;
padding: 10px;
background-color: #4CAF50;
color: white;
border: none;
border-radius: 4px;
cursor: pointer;

.login-form button:hover {
background-color: #45a049;

In the above CSS code, we define styles for the login container, header, input fields, and submit button. We set the maximum width, margin, padding, border, and background color for the login container. The login header is centered and has some margin-bottom for spacing. The input fields have a display of block, width of 100%, and some padding and border. The submit button has a background color, padding, border-radius, and cursor style. On hover, the button changes its background color to provide visual feedback.

Adding Personal Touches

To add some personal touches to our login page, we can customize the logo and the welcome message. You can replace the default logo image with your custom logo by updating the <img> tag’s “src” attribute. Additionally, you can modify the welcome message by changing the text inside the <h1> tag. This will make the login page feel more unique and branded to your website.


In this article, we’ve explored how to create a login page using HTML and CSS. By following the provided code examples and adding personal touches, you can create a visually appealing login page that seamlessly integrates with your website’s design. Remember to test your login page thoroughly and consider adding additional security measures, such as password encryption, to protect your users’ information. Happy coding!