How to create footer to stay at the bottom of a Web page?

To create a footer to stay at the bottom of a web page We can fix the position of it at the bottom of the webpage so that, if you scroll down that webpage you can still view the footer from any position at the page.
To make a footer fixed at the bottom of the webpage, you could use position: fixed.

Syntax:

#footer {
   position:absolute;
   bottom:0;
   width:100%;
   height:60px;   /* Height of the footer */
   background:#6cf;
}

Example:

filter_none

edit
close

play_arrow

link
brightness_4
code

<html>
  
<head>
    <style>
        #footer {
            position: fixed;
            padding: 10px 10px 0px 10px;
            bottom: 0;
            width: 100%;
            /* Height of the footer*/ 
            height: 40px;
            background: grey;
        }
    </style>
  
    <head>
  
        <body>
            <center>
                <div id="container">
                    <h1>GeeksforGeeks</h1>
                    <h1>GeeksforGeeks</h1>
                    <h1>GeeksforGeeks</h1>
                    <h1>GeeksforGeeks</h1>
                    <h1>GeeksforGeeks</h1>
                    <h1>GeeksforGeeks</h1>
                    <h1>GeeksforGeeks</h1>
                    <h1>GeeksforGeeks</h1>
                    <h1>GeeksforGeeks</h1>
                    <h1>GeeksforGeeks</h1>
                    <h1>GeeksforGeeks</h1>
                    <h1>GeeksforGeeks</h1>
                    <div id="footer">This is a footer.
                      This stays at the bottom of the page.
                  </div>
                </div>
            </center>
        </body>
        <html>

chevron_right


Output:



My Personal Notes arrow_drop_up

Check out this Author's contributed articles.

If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.

Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.




Article Tags :

Be the First to upvote.


Please write to us at contribute@geeksforgeeks.org to report any issue with the above content.