Materialize CSS | Footer

Footer is an effective way to organize a lot of site navigation and information at the end of a page. This is the place where a user will look once they have finished scrolling through the current page or are looking for additional information about the website.

Flexbox is used to structure the html so that the footer is always on the bottom of the page. It is important to keep the structure of page within the three HTML5 tags <header>, <main> and <footer> as shown below.

filter_none

edit
close

play_arrow

link
brightness_4
code

<body>
    <header></header>
    <main></main>
    <footer></footer>
</body>

chevron_right


Example:

HTML

filter_none

edit
close

play_arrow

link
brightness_4
code

<!DOCTYPE html>
<html>
  
<head>
  <title>
    The Materialize Footer Example
  </title>
  <meta name="viewport" content=
    "width=device-width, initial-scale=1">
  <link rel="stylesheet" href=
  <script src=
  </script>
</head>
  
<body class="container">
  
  <!-- Define the footer -->
  <footer class="page-footer green">
    <div class="container ">
      <div class="row">
        <div class="col l6 s12">
          <h5 class="white-text">
            Footer Content
          </h5>
          <p class="grey-text text-lighten-4">
            Rows and columns are
            used to organize the footer content.
          </p>
  
        </div>
        <div class="col l4 offset-l2 s12">
          <h5 class="white-text">Links</h5>
          <ul>
            <li>
              <a class="grey-text text-lighten-3" href="#!">
                Link 1
              </a>
            </li>
            <li>
              <a class="grey-text text-lighten-3" href="#!">
                Link 2
              </a>
            </li>
            <li>
              <a class="grey-text text-lighten-3" href="#!">
                Link 3
              </a>
            </li>
          </ul>
        </div>
      </div>
    </div>
    <div class="footer-copyright green darken-3">
      <div class="container ">
        © 2020 Copyright Text
        <a class="grey-text text-lighten-4 right" href="#!">
          More Links
        </a>
      </div>
    </div>
  </footer>
</body>
  
</html>

chevron_right


Output:



Sticky Footer: A sticky footer always stays on the bottom of the page regardless of how little content is on the page. However, this footer will be pushed down if there is a lot of content, so it is different from a fixed footer. Add the following code to your CSS file.

  body {
    display: flex;
    min-height: 100vh;
    flex-direction: column;
  }

  main {
    flex: 1 0 auto;
  }

Example:

HTML

filter_none

edit
close

play_arrow

link
brightness_4
code

<!DOCTYPE html>
<html>
  
<head>
  <title>
    The Materialize Footer Example
  </title>
  <meta name="viewport" content=
    "width=device-width, initial-scale=1">
  
  <link rel="stylesheet" href=
  <script src=
  </script>
  
  <style>
    /* Add CSS for making the
    footer sticky */
    body {
      display: flex;
      min-height: 100vh;
      flex-direction: column;
    }
  
    main {
      flex: 1 0 auto;
    }
  </style>
</head>
  
<body class="container">
  
  <!-- Use the <main> tag for displaying
       the contents of the page -->
  <main>
    <h1 style="color: green;">
      GeeksforGeeks
    </h1>
  
    <p>
      A Computer Science portal for geeks.
    </p>
  
  </main>
  
  <!-- Define the footer -->
  <footer class="page-footer green">
    <div class="container ">
      <div class="row">
        <div class="col l6 s12">
          <h5 class="white-text">
            Footer Content
          </h5>
          <p class="grey-text text-lighten-4">
            Rows and columns are
            used to organize the footer content.
          </p>
  
        </div>
        <div class="col l4 offset-l2 s12">
          <h5 class="white-text">Links</h5>
          <ul>
            <li>
              <a class="grey-text 
                text-lighten-3" href="#!">
                Link 1
              </a>
            </li>
            <li>
              <a class="grey-text 
                text-lighten-3" href="#!">
                Link 2
              </a>
            </li>
            <li>
              <a class="grey-text 
                text-lighten-3" href="#!">
                Link 3
              </a>
            </li>
          </ul>
        </div>
      </div>
    </div>
    <div class="footer-copyright green darken-3">
      <div class="container ">
        © 2020 Copyright Text
        <a class="grey-text 
          text-lighten-4 right" href="#!">
          More Links
        </a>
      </div>
    </div>
  </footer>
</body>
  
</html>

chevron_right


Output:

full-stack-img




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 :
Practice Tags :


Be the First to upvote.


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