The Wayback Machine - https://web.archive.org/web/20240928101033/https://www.geeksforgeeks.org/html-login-form/
Open In App

HTML Login Form

Last Updated : 03 Jun, 2024
Summarize
Comments
Improve
Suggest changes
Like Article
Like
Save
Share
Report
News Follow

HTML Login Form is a foundational element in web development. It is used to authenticate users and grant access to secure sections of a website or application. It typically includes input fields for username/email and password, along with a submit button for logging in. Additionally, there is often an option for new users to create an account or sign up.

Upon clicking the submit button, the form sends the user’s entered credentials to the server for verification. If the provided credentials are valid, the user is successfully logged in and granted access to the site’s protected content. However, if the credentials are incorrect, an error message is displayed, prompting the user to retry entering the correct information.

Overall, the HTML Login Form plays a crucial role in ensuring the security and accessibility of web applications by managing user authentication processes effectively.

Steps to Create an HTML Login Form

The following steps are required to create the login form in HTML:

1. Set up the HTML Document

Start with a basic HTML document structure:

2. Create the Form Element

  • Within the <body> tag, add a <form> element.
  • Set the action attribute to the URL where the form data will be sent (usually to a server-side script).
  • Set the method attribute to “POST” to send the data securely.

3. Add Input Fields

  • Inside the <form> element, create input fields for username and password:
  • Use the <input> tag with the type attribute set to “text” for username.
  • Use the <input> tag with the type attribute set to “password” for password.
  • Add clear labels for each input field using the <label> tag.

4. Include a Submit Button:

  • Add a submit button using the <button> tag with the type attribute set to “submit“.
  • Give the button a clear label describing its action, like “Login” or “Submit“.

5. Optional: Add Additional Features:

  • Include a “Remember Me” checkbox using the <input> tag with the type attribute set to “checkbox“.
  • Add a link to “Forgot Password” page using the <a> tag.
  • Add styling using CSS for a more appealing look.

6. Close the Form and Document:

  • Close the <form> tag.
  • Add the closing </body> and </html> tags to complete the document.

Example: To demonstrate creating an HTML Login Form with Multiple Input Tags.

HTML
<!DOCTYPE html>
<html>

<head>
      <title>HTML Login Form</title>
      <link rel="stylesheet" href="style.css">
</head>

<body>
      <div class="main">
            <h1>GeeksforGeeks</h1>
            <h3>Enter your login credentials</h3>
            <form action="">
                  <label for="first">
                        Username:
                  </label>
                  <input type="text" 
                         id="first" 
                         name="first" 
                         placeholder="Enter your Username" required>

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

                  <div class="wrap">
                        <button type="submit"
                                onclick="solve()">
                              Submit
                        </button>
                  </div>
            </form>
            <p>Not registered?
                  <a href="#"
                     style="text-decoration: none;">
                        Create an account
                  </a>
            </p>
      </div>
</body>

</html>
CSS
/*style.css*/
body {
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: sans-serif;
    line-height: 1.5;
    min-height: 100vh;
    background: #f3f3f3;
    flex-direction: column;
    margin: 0;
}

.main {
    background-color: #fff;
    border-radius: 15px;
    box-shadow: 0 0 20px rgba(0, 0, 0, 0.2);
    padding: 10px 20px;
    transition: transform 0.2s;
    width: 500px;
    text-align: center;
}

h1 {
    color: #4CAF50;
}

label {
    display: block;
    width: 100%;
    margin-top: 10px;
    margin-bottom: 5px;
    text-align: left;
    color: #555;
    font-weight: bold;
}


input {
    display: block;
    width: 100%;
    margin-bottom: 15px;
    padding: 10px;
    box-sizing: border-box;
    border: 1px solid #ddd;
    border-radius: 5px;
}

button {
    padding: 15px;
    border-radius: 10px;
    margin-top: 15px;
    margin-bottom: 15px;
    border: none;
    color: white;
    cursor: pointer;
    background-color: #4CAF50;
    width: 100%;
    font-size: 16px;
}

.wrap {
    display: flex;
    justify-content: center;
    align-items: center;
}

Output:

Example of Login Form in HTML Output

Previous Article
Next Article

Similar Reads

Basic Registration and Login Form Using React Hook Form
In ReactJS, creating a form can be a nightmare as it involves handling inputs and validating inputs. React-hook-form is a ReactJS library that simplifies the process of creating forms. The library provides all the features that a modern form needs. It is simple, fast, and offers isolated re-renders for elements. In this article, we will learn how t
6 min read
LinkedIn Login Form Using HTML and CSS
Nowadays, a professional website LinkedIn very popular. This UI has generally seen on the “LinkedIn” website. In this article, we will create a LinkedIn Login UI using HTML and CSS. Below are the two steps on how to do it. This will help the beginner to build some awesome UI using HTML and CSS by referring to this article. Before the code, you just
3 min read
How to Add a Login Form to an Image using HTML and CSS?
The login form on an Image is used on many websites. Like hotel websites that contain pictures of the hotels or some organizations that organize special events holding that event picture and login form. In that case, you can design a login or registration form on that picture. This design will make the website more attractive than a regular login o
2 min read
HTML Neumorphism Login Form
Neumorphism combines developments of flat design and skeuomorphism. Neumorphism, or soft UI, is a visual style that combines background colors, shapes, gradients, highlights, and shadows to ensure graphic intense buttons and switches. All that allows achieving a soft, extruded plastic look, and almost 3D styling. For a better understanding visit: h
3 min read
Design a Responsive Sliding Login & Registration Form using HTML CSS & JavaScript
In this article, we will see how to create the Responsive Sliding Login & Registration Form using HTML CSS & JavaScript, along with understanding its implementation through the illustration. Many websites, nowadays, implement sliding login & registration forms for their sites. A Registration form is used to register or create a new acco
5 min read
How to Create Glassmorphism Login Form in HTML and CSS ?
Glassmorphism, characterized by its transparent and frosted glass-like appearance, provides a visually appealing user interface. The login form will feature translucent backgrounds, blurred elements, and subtle shadows to achieve the Glassmorphism effect. the step-by-step process of designing and coding a stunning Glassmorphism login form that can
3 min read
How to make responsive sliding login and registration form using HTML CSS and JavaScript ?
In this article, we will learn how to make responsive sliding login and registration forms using HTML, CSS, and javascript. Forms are used on webpages for the user to enter their required details that further send to the server for processing. A form is also known as a web form or HTML form. In this article, you will learn to make a responsive slid
4 min read
HTML Responsive Modal Login Form
An HTML Responsive Modal Login Form is a popup form designed to request user credentials, such as a username and password, within a modal window. It adapts to different screen sizes, ensuring usability on various devices, from desktops to smartphones, without affecting the overall layout. Preview: Approach:HTML Structure: Create a button to trigger
4 min read
How to create a Social Media Login Form using CSS ?
To create a social media login form using CSS, we will design a container with input fields for a username or password and a login button. In this social media login form, we will enhance the interface with distinct styling, and integrate social media icons or buttons for a user-friendly and visually appealing login experience. Preview: Approach:Fi
3 min read
Tailwind CSS Login Form
Login forms in Tailwind CSS are sections of a document on websites that are used for user authentication, web security, accessibility, and to gain access to restricted areas. A typical login form consists of two input fields, i.e., one for the user’s username and the other for their password. It also includes a submit button that, when clicked, sen
3 min read
Create a Social Media Login Form using Tailwind CSS
The social media login page allows users to log in using their email and password or through various social media platforms such as Facebook, Twitter, Google, and Instagram. Here we will create a social media login page using Tailwind CSS. PrerequisitesHTML JavaScriptTailwind CSSApproachHTML Structure: Defines the layout of the login form, includin
2 min read
Bootstrap Login Form
A Bootstrap Login Form refers to a web interface designed using the Bootstrap framework, offering a responsive layout for users to input credentials for authentication, typically comprising fields for username/email and password, often with additional features like validation and customization. #content-iframe{width: 100%; height: 600px;} @media (m
2 min read
Login form using Node JS and MongoDB
Follow these simple steps to learn how to create a login form using Node.js and MongoDB. Node JS login form allows users to log in to the website after they have created their account using the signup form. We will be using the following technologies: Express:It is a small framework that sits on top of Node.js’s web server functionality to simplify
5 min read
How to Create a Responsive Login Form in Navbar using CSS?
A Responsive Login form in the Navbar allows users to log in from any page of the website without navigating to a separate login page. This article explains how to create a Responsive Login form within a Navbar using CSS. ApproachStart by creating a <nav> element to contain the navbar.Inside the <nav> create a <div> element for th
3 min read
Design a transparent login/Sign Up webpage using HTML and CSS
Project Introduction: In this article, we will discuss how to design a transparent login webpage using HTML and CSS. Project Structure: index.htmlstyle.css index.html Explanation: We have put the login form in a class called container and we have placed each input tag in a separate div with class row so that each input tag occupies the full line. W
3 min read
How to Create Facebook Login Page in HTML & CSS ?
To Create a Facebook Login Page in HTML and CSS we will first create the overall structure of the application and then apply the styling and formatting properties using CSS. The application consists of exactly a similar design to the Facebook Login Page. The application is designed in a responsive and user-friendly manner. ApproachFirstly use HTML
4 min read
How to Create Netflix Login Page in HTML & CSS ?
To create a Netflix login page using HTML and CSS, we will design a layout that includes elements such as a login form, Netflix logo, and footer. We will use CSS for styling, including background images, fonts, colors, and layout adjustments for responsiveness. In the below section, we have the complete implementation to Create a Netflix Login Page
4 min read
How to create Twitter Login Page using HTML CSS JavaScript ?
In this article, we will see How To Make a Twitter Login Page Like Using HTML CSS JavaScript. The code produces an attractive login page with a design similar to the Twitter login interface. The JavaScript incorporates straightforward validation for the email input field upon submitting the form. Preview ApproachCreate a div, button, input text, an
4 min read
Automated Login For Captive Portals in Linux
Every time you connect to a private network, may it be your college, office, school, etc. the captive portal screen appears where you have to enter your credentials provided by the organization. The idea is to automate that process so that whenever we are connected to any router in the same network, it automatically gets logged in. Note: In the fol
7 min read
How to implement Facebook login in your Web app with Firebase ?
Firebase offers a great number of options to implement Login in your app. Some of which are: Using Email.Using Phone number.Using Facebook.Using Google, etc. The best part is you don't have to worry about handling the login flow, Firebase takes care of it. Approach: First of all, create a Firebase project by following these steps: Go to https://con
3 min read
How to implement Google Login in your Web app with Firebase ?
Firebase offers a great number of options to implement Login in your app. Some of which are: Using Email.Using Phone number.Using Google.Using Facebook etc. The best part is you don't have to worry about handling the login flow, Firebase takes care of it. Approach: First of all, create a Firebase project by following these steps: Go to https://cons
3 min read
Login and Registration Project Using Flask and MySQL
Project Title: Login and registration Project using Flask framework and MySQL Workbench. Type of Application (Category): Web application. Introduction: A framework is a code library that makes a developer's life easier when building web applications by providing reusable code for common operations. There are a number of frameworks for Python, inclu
6 min read
How to design login dialog using jQuery EasyUI Mobile ?
EasyUI is a HTML5 framework for using user interface components based on jQuery, React, Angular and Vue technologies. It helps in building features for interactive web and mobile applications saving a lot of time for developers. In this article, we will learn to design login dialog and message dialog for mobiles using jQuery EasyUI plugin. Download
3 min read
Understanding Web Authentication behind the login screen
Authentication is the process of verifying the identity of a user or information. User authentication is the process of verifying the identity of the user when that user logs in to a computer system. The article briefly deals with authentication in modern web applications. The two primary types of authentication are: Stateless AuthenticationStatefu
3 min read
Blaze UI Example Login
Blaze UI is a framework-free open source UI toolkit that uses JavaScript components to build great user interfaces. It is the same as a bootstrap for use and has great different elements to use to make your website look more amazing. This framework allows us to use various of its styles and properties to make a website more user-friendly. In this a
3 min read
Struts2 Login Page with Validation
Apache Struts 2 is an open-source web application framework for developing Java EE web applications. It uses and extends the Java Servlet API to encourage developers to adopt a model–view–controller architecture. In this article, we will see how we can create a login page with validations using Struts 2. We will use struts UI tags to create a login
6 min read
Create a Simple Login Web Application with Encrypted Password in Java
Security is an important concept in any web application. We need to have the passwords stored in an encrypted way i.e. the passwords are not easily accessible by hackers or unauthorized users. Let's see a small demo application in this article using MySQL, Java, Servlet, and JSP technology. Step by Step Implementation Required MySQL Script -- Here
10 min read
React Suite Container Login Page Layout
React suite is a library of React components, sensible UI design, and a friendly development experience. It is supported in all major browsers. It provides pre-built components of React which can be used easily in any web application. In this article, we'll learn about React suite Container Login Page Layout. The container layout can define the mai
3 min read
Create Twitter Login Page using Tailwind & jQuery
We will see How To Make a Twitter Login Page Using TailwindCSS and jQuery. The code produces an attractive login page with a design similar to the Twitter login interface. The jQuery incorporates straightforward validation for the email input field upon submitting the form. PrerequisitesHTMLTailwind CSSjQueryApproachThe HTML code outlines a basic l
2 min read
Spring Security Login Page with React
Spring Security is the most powerful and highly customizable authentication, and it is access control framework for Java enterprise applications and React is a popular JavaScript library for building for the user interfaces. Integrating Spring Security with the React frontend allows you to create the secure login pages and protect your application'
15 min read