How to Create a Sticky Footer Using CSS Flexbox? Last Updated : 29 Jul, 2024 Comments Improve Suggest changes Like Article Like Report Creating a sticky footer using CSS Flexbox ensures that the footer remains at the bottom of the viewport or the content and provide a consistent layout experience. In this article we will cover approach to create a sticky footer using CSS Flexbox.ApproachSet the html and body elements to 100% height and remove default margins.Style the body to be a flex container with a column direction to allow easy management of the header, main content, and footer.Create a .container div to hold the header, main content, and footer.Set the container to flex: 1 to expand and take up available space, and add padding at the bottom to prevent content from being hidden behind the footer.Style the footer to be positioned fixed at the bottom of the viewport using position: fixed.Example: In below example we have created sticky footer which remain sticky even if we scroll down. HTML <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>Sticky Footer</title> <link rel="stylesheet" href="style.css"> </head> <body> <div class="container"> <header> <h1>Course Offerings</h1> </header> <main> <h2>Hello, What Do You Want To Learn?</h2> <div class="card"> <h2>DSA Self-Paced</h2> <p>Learn Data Structures and Algorithms at your own pace with our comprehensive course.</p> <a href="#">Learn More</a> </div> <div class="card"> <h2>JavaScript Fundamentals</h2> <p>Master the fundamentals of JavaScript, the language of the web.</p> <a href="#">Learn More</a> </div> <div class="card"> <h2>React MERN Stack</h2> <p>Become proficient in building full-stack applications with the MERN stack (MongoDB, Express, React, Node.js).</p> <a href="#">Learn More</a> </div> </main> <footer> <p>@GeeksforGeeks, Sanchhaya Education Private Limited, All rights reserved </p> </footer> </div> </body> </html> CSS html, body { height: 100vh; margin: 0; } body { display: flex; flex-direction: column; margin: 0; } /* Main container to hold header, // main content, and footer */ .container { flex: 1; display: flex; flex-direction: column; padding-bottom: 3rem; } header { background-color: #f1f1f1; padding: 1rem; text-align: center; } main { flex: 1; padding: 1rem; min-height: 100vh; } .card { border: 1px solid #ddd; border-radius: 5px; padding: 1rem; margin: 1rem 0; box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1); } .card h2 { margin-top: 0; } .card p { margin: 0.5rem 0; } .card a { display: inline-block; margin-top: 0.5rem; padding: 0.5rem 1rem; color: white; background-color: #007bff; text-decoration: none; border-radius: 5px; } .card a:hover { background-color: #0056b3; } /* Footer styling */ footer { position: fixed; bottom: 0; left: 0; width: 100%; background-color: rgb(123, 196, 123); color: white; text-align: center; padding: 1rem; } Output:Output Comment G ghuleyogesh Follow 0 Improve G ghuleyogesh Follow 0 Improve Article Tags : HTML CSS-Questions Explore HTML BasicsHTML Introduction5 min readHTML Editors5 min readHTML Basics7 min readStructure & ElementsHTML Elements5 min readHTML Attributes8 min readHTML Headings4 min readHTML Paragraphs5 min readHTML Text Formatting4 min readHTML Block and Inline Elements3 min readHTML Charsets4 min readListsHTML Lists5 min readHTML Ordered Lists5 min readHTML Unordered Lists4 min readHTML Description Lists3 min readVisuals & MediaHTML Colors11 min readHTML Links Hyperlinks3 min readHTML Images7 min readHTML Favicon4 min readHTML Video4 min readLayouts & DesignsHTML Tables10 min readHTML Iframes4 min readHTML Layout4 min readHTML File Paths3 min readProjects & Advanced TopicsHTML Forms5 min readHTML5 Semantics6 min readHTML URL Encoding4 min readHTML Responsive Web Design11 min readTop 10 Projects For Beginners To Practice HTML and CSS Skills8 min readTutorial ReferencesHTML Tags - A to Z List15+ min readHTML Attributes Complete Reference8 min readHTML Global Attributes5 min readHTML5 Complete Reference8 min readHTML5 MathML Complete Reference3 min readHTML DOM Complete Reference15+ min readHTML DOM Audio/Video Complete Reference2 min readSVG Element Complete Reference5 min readSVG Attribute Complete Reference8 min readSVG Property Complete Reference7 min readHTML Canvas Complete Reference4 min read Like