Create a Stacked Form using CSS Last Updated : 24 May, 2024 Summarize Comments Improve Suggest changes Share Like Article Like Report A stacked form layout is a common design pattern where form elements are displayed vertically, one on top of the other. This layout is often used for simplicity and clarity in user interfaces. In this article, we will explore the process of creating a Stacked Form using CSS. ApproachCreate a <div> element with a class of "form-container" to hold the form inside <body>.Create a <form> element to encapsulate the form fields within the "form-container" <div>.Inside the <form> element, create form fields using <div> elements with a class of "form-group".Add <input> elements for each form field with appropriate type attributes such as "text", "password", "email", "tel", etc, and set the id and name attributes accordingly.Ensure that all required fields are marked with the "required" attribute.Add a "required" attribute for each field for form validation.Define CSS styles for the form container, form groups, labels, input fields, and submit button.Example: Implementation To Create a Stacked Form using CSS. HTML <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title> Stacked Form</title> <style> body { font-family: Arial, sans-serif; background-color: #f4f4f4; } .form-container { max-width: 400px; margin: 50px auto; padding: 20px; background-color: #fff; border-radius: 8px; box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1); border: 2px solid #007bff; } .form-group { margin-bottom: 20px; } label { display: block; margin-bottom: 5px; color: #333; } input[type="text"], input[type="password"], input[type="email"], input[type="tel"], button { width: 95%; padding: 10px; border: 1px solid #ccc; border-radius: 5px; transition: border-color 0.3s ease; } input[type="text"]:focus, input[type="password"]:focus, input[type="email"]:focus, input[type="tel"]:focus { border-color: dodgerblue; outline: none; } button { background-color: dodgerblue; width: 100%; color: #fff; cursor: pointer; transition: background-color 0.3s ease; } button:hover { background-color: #007bff; } h2{ text-align: center; color: green; } h3{ text-align: center; } </style> </head> <body> <div class="form-container"> <h2>Welcome to GeeksForGeeks</h2> <h3>Stacked form</h3> <form> <div class="form-group"> <label for="username">Username:</label> <input type="text" id="username" name="username" required> </div> <div class="form-group"> <label for="password">Password:</label> <input type="password" id="password" name="password" required> </div> <div class="form-group"> <label for="email">Email:</label> <input type="email" id="email" name="email" required> </div> <div class="form-group"> <label for="phone">Phone:</label> <input type="tel" id="phone" name="phone" required> </div> <button type="submit">Submit</button> </form> </div> </body> </html> Output: Comment More infoAdvertise with us Next Article How to Create a Stacked Form using CSS ? G ghuleyogesh Follow Improve Article Tags : Web Technologies CSS Similar Reads How to Create a Stacked Form using CSS ? A Vertically Stacked Form places labels and inputs on top of each other. To create a stacked form using CSS, we will first define a container with a maximum width, padding, and border radius for styling. Preview: Approach:Begin by creating the basic HTML structure, including the form container and f 2 min read Create a Contact Form using HTML CSS & JavaScript A contact form is a web form used to collect user information and messages, facilitating communication between visitors and site owners. It is essential for feedback, inquiries, and support. Create a contact form using HTML for structure, CSS for styling, and JavaScript for validation and submission 3 min read Design a Contact Form Using Tailwind CSS A Contact Form Builder is a web application that allows users to create custom contact forms for their websites with ease. This Tailwind project aims to build a user-friendly interface for creating and customizing contact forms.Approach:Design a simple and intuitive UI using the Tailwind CSS for the 2 min read How to create a Responsive Inline Form using CSS ? When the browser window is resized, the labels and inputs will stack on top of each other for smaller screens. To create a responsive inline form using CSS, use a container with flexible styling, such as Flexbox or Grid, to arrange form elements horizontally. Utilize media queries to adjust the layo 3 min read how to create a responsive checkout form using CSS Creating a responsive checkout form using CSS ensures that users can efficiently and comfortably enter their billing and payment information on any device.ApproachCreate a form that is wrapped inside a <form> tag.Inside the form create two sections for "Address Details" and "Payment Informatio 3 min read Pure CSS Stacked Form Pure CSS is a framework of CSS. It is a free and open-source tool collection for creating responsive websites and web applications. Pure CSS is developed by Yahoo and is used for creating faster, beautiful, and responsive websites. It can be used as an alternative to Bootstrap. In this article, we w 2 min read Like