How to keep footer at bottom of screen

HtmlCss

Html Problem Overview


What is best practice for setting up a web page so that if there is very little content/text to be displayed on that web page the footer is displayed at the bottom of the browser window and not half way up the web page?

Html Solutions


Solution 1 - Html

What you’re looking for is the CSS Sticky Footer.

* {
  margin: 0;
  padding: 0;
}

html,
body {
  height: 100%;
}

#wrap {
  min-height: 100%;
}

#main {
  overflow: auto;
  padding-bottom: 180px;
  /* must be same height as the footer */
}

#footer {
  position: relative;
  margin-top: -180px;
  /* negative value of footer height */
  height: 180px;
  clear: both;
  background-color: red;
}


/* Opera Fix thanks to Maleika (Kohoutec) */

body:before {
  content: "";
  height: 100%;
  float: left;
  width: 0;
  margin-top: -32767px;
  /* thank you Erik J - negate effect of float*/
}

<div id="wrap">
  <div id="main"></div>
</div>

<div id="footer"></div>

Solution 2 - Html

You could use position:fixed; to bottom.

eg:

#footer{
 position:fixed;
 bottom:0;
 left:0;
}

Solution 3 - Html

HTML

<div id="footer"></div>

CSS

#footer {
   position:absolute;
   bottom:0;
   width:100%;
   height:100px;   
   background:blue;//optional
}

Solution 4 - Html

set its position:fixed and bottom:0 so that it will always reside at bottom of your browser windows

Solution 5 - Html

Perhaps the easiest is to use position: absolute to fix to the bottom, then a suitable margin/padding to make sure that the other text doesn't spill over the top of it.

css:

<style>
  body {
    margin: 0 0 20px;
  }
  .footer {
    position: absolute;
    bottom: 0;
    height: 20px;
    background: #f0f0f0;
    width: 100%;
  }
</style>

Here is the html main content.

<div class="footer"> Here is the footer. </div>

Solution 6 - Html

use this style

min-height:250px;
height:auto;

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestiongraburyView Question on Stackoverflow
Solution 1 - HtmlJezen ThomasView Answer on Stackoverflow
Solution 2 - HtmlChamara KeragalaView Answer on Stackoverflow
Solution 3 - HtmlSasidharanView Answer on Stackoverflow
Solution 4 - HtmlGanesh PandhereView Answer on Stackoverflow
Solution 5 - HtmlSeth JefferyView Answer on Stackoverflow
Solution 6 - Htmlvishal shahView Answer on Stackoverflow